Implementing PPR in an Adapter
Implement Partial Prerendering support in an adapter using fallback output and cache hooks.
For partially prerendered app routes, onBuildComplete gives you the data needed to seed and resume PPR:
outputs.prerenders[].fallback.filePath: path to the generated fallback shell (for example HTML)outputs.prerenders[].fallback.postponedState: serialized postponed state used to resume rendering
1. Seed shell + postponed state at build time
2. Runtime flow: serve cached shell and resume in background
At request time, you can stream a single response that is the concatenation of:
- cached HTML shell stream
- resumed render stream (generated after invoking
handlerwith postponed state)
3. Update cache with requestMeta.onCacheEntryV2
requestMeta.onCacheEntryV2 is called when a response cache entry is looked up or generated. Use it to persist updated shell/postponed data.
[!NOTE]
requestMeta.onCacheEntrystill works, but is deprecated.- Prefer
requestMeta.onCacheEntryV2. - If your adapter uses an internal
onCacheCallbackabstraction, wire it torequestMeta.onCacheEntryV2.