cdb415451a
Enabling Partial Prerendering (PPR) for an entire application is ideally, the goal for teams wanting to test out the feature or adopt it in their applications to get ready for when it becomes the default rendering pattern. For large applications, with many routes the new behaviours of old API's may prove a difficult pill to swallow all at once. This aims to enable incremental adoption of PPR for pages and routes that want to support it in a similar way to how existing segment-level configurations. Segments can now add: ```ts export const experimental_ppr = true ``` To enable PPR for that segment and those descending segments. Any subset of those routes that have it enabled can add: ```ts export const experimental_ppr = false ``` <details> <summary>An aside on the choice of <code>experimental_ppr</code> name</summary> <blockquote> <p>It is against common JS semantics to use snake-case, and preference is given to camel-case instead. The choice to make this snake-case was to re-enforce that this is an experimental feature, an ugly incremental path, and ideally, developers should aim to remove all references of it from their codebase.</p> <p>Additionally, this mirrors what we've done for unstable API's like `unstable_cache`.</p> </blockquote> </details> To disable PPR for that segment and those descending segments. To use this new option, the `experimental.ppr` configuration in `next.config.js` must be set to `"incremental"`: ```js // next.config.js module.exports = { experimental: { ppr: "incremental", }, } ``` If a segment does not export a `experimental_ppr` boolean, it is inferred from it's parent. If no parent has it defined, it's default value is `false` and therefore disabled. Once all your segments have PPR enabled via this config, it would be considered safe for teams to set their `experimental.ppr` value in the `next.config.js` to `true`, enabling it for the entire app and for all future routes. ### Aside I also took the liberty to rename `isPPR` and `supportsPPR` to be the clearer `isAppPPREnabled` and `isRoutePPREnabled`. --------- Co-authored-by: Hendrik Liebau <mail@hendrik-liebau.de> |
||
---|---|---|
.. | ||
app | ||
lib | ||
next.config.js | ||
ppr-incremental.test.ts |