Next.js Discord

Discord Forum

NextJS Page become dynamic once Navbar auth is loaded in server side

Unanswered
Boerboel posted this in #help-forum
Open in Discord
BoerboelOP
I noticed my whole page becomes dynamic when I put a function that calls in asynchronous await to see if user is logged in or not. The only option it fixed was making it a client component so then it become static. Please explain how the whole thing becomes dynamic.

3 Replies

If you await a function that needs request-time data (user session - cookies) inside the Layout it makes sense to turn dynamic all pages under that layout
Pages or components that access to dynamic APIs that require request-time data need to be wrapped in <Suspense> (add a loading.tsx for pages) to let Next.js pre-render as much as possible until it reaches a Suspense, sending the suspense fallback first and then streaming down the Actual component as it becomes ready