Dynamic header on a static page #51187
Unanswered
nedak96
asked this question in
App Router
Replies: 1 comment
-
|
Partial Prerendering might help you out with this though it is currently experimental. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello! I'm curious if there is any guidance on how to go about having some dynamic content based on auth state, but otherwise having static content. Here is a basic example
layout.tsx
page.tsx
(I want to statically generate this content)
When I build this page, I get the message
warn Entire page / deopted into client-side renderingand the page refetches the data on every load and SSR the HTML. I know the dynamic header would need to be SSR'd, but I'm less worried about that.One solution that seems to work is separating these into two pages and using middleware to rewrite based on auth state
middleware.ts
layout.tsx
(authenticatedRoutes)/layout.tsx
(authenticatedRoutes)/protected/page.tsx
(unauthenticatedRoutes)/layout.tsx
(unauthenticatedRoutes)/page.tsx
This seems to work, but there is much more code than I'd like there to be. Does anyone have guidance on the best way to do this? Maybe just caching the db response is enough, or maybe even conditional parallel routes. Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions