Context
Follow-up from the retained RC3 application validation in better-stack-web#37, with the failed intermediate diagnosis captured in #245.
This is a post-v3 incremental DX improvement. It must not block or reopen v3.
Friction
A real Next.js migration initially placed request-aware BTST pages and ISR pages under the same physical app/p segment/layout. The resulting symptoms did not identify the routing mistake:
- the request-aware loader prefetched protected data successfully with session headers;
- the plugin suspense query then refetched through the browser/static stack without headers;
- the API returned 401;
- React reported an authentication error, hydration failure, and client-render fallback.
That looked like a broken initialIdentity or query hydration contract and was substantial enough to produce an upstream bug report. The actual fix was the documented physical split:
app/(request)/p/... -> createNextLayout + request-aware createNextPage
app/(static)/p/... -> header-free static provider/ISR pages
The architecture is valid, but the failure mode is too indirect.
Proposed better alternative
Add explicit rendering intent and development-time diagnostics without breaking the RC3 helpers.
- Add named incremental aliases or wrappers:
createNextRequestLayout / createNextRequestPage
createNextStaticLayout / createNextStaticPage
- Brand the produced stack/layout context with
rendering: "request" | "static" in development builds.
- Detect incompatible composition where possible: a request-prefetched query rendering through a static/browser stack, a static page under a request identity layout, or different query-client identities across prefetch/provider hydration.
- Throw one actionable development error before the suspense query runs, including the canonical route-group tree and a link to the Next integration guide.
- Add an optional repository lint/check that can inspect
app/ and flag BTST request/static pages sharing an incompatible layout segment. Runtime code cannot infer the full filesystem shape, so diagnostics and static inspection should complement each other.
Example diagnostic:
[btst/next] Request-prefetched data is rendering through a static/browser stack.
Separate request-aware and static pages into parallel route groups and ensure
createNextPage and StackProvider share the same QueryClient.
Keep createNextPage and createNextLayout as supported aliases so this ships as an incremental minor update.
Acceptance criteria
Relationship to existing docs work
#175 should document the correct architecture. This issue adds API affordances and diagnostics so a mistake does not require source-level debugging after the guide has been followed imperfectly.
Release boundary
Post-v3 enhancement only. Do not hold v3 publication or require an RC4 for this issue.
Context
Follow-up from the retained RC3 application validation in better-stack-web#37, with the failed intermediate diagnosis captured in #245.
This is a post-v3 incremental DX improvement. It must not block or reopen v3.
Friction
A real Next.js migration initially placed request-aware BTST pages and ISR pages under the same physical
app/psegment/layout. The resulting symptoms did not identify the routing mistake:That looked like a broken
initialIdentityor query hydration contract and was substantial enough to produce an upstream bug report. The actual fix was the documented physical split:The architecture is valid, but the failure mode is too indirect.
Proposed better alternative
Add explicit rendering intent and development-time diagnostics without breaking the RC3 helpers.
createNextRequestLayout/createNextRequestPagecreateNextStaticLayout/createNextStaticPagerendering: "request" | "static"in development builds.app/and flag BTST request/static pages sharing an incompatible layout segment. Runtime code cannot infer the full filesystem shape, so diagnostics and static inspection should complement each other.Example diagnostic:
Keep
createNextPageandcreateNextLayoutas supported aliases so this ships as an incremental minor update.Acceptance criteria
(request)/(static)file tree.Relationship to existing docs work
#175 should document the correct architecture. This issue adds API affordances and diagnostics so a mistake does not require source-level debugging after the guide has been followed imperfectly.
Release boundary
Post-v3 enhancement only. Do not hold v3 publication or require an RC4 for this issue.