Next.js Discord

Discord Forum

All my routes are dynamically rendered

Unanswered
Giant resin bee posted this in #help-forum
Open in Discord
Giant resin beeOP
I created a crm in which i simply fetch the data from my database and display it, all routes are supposed to be static, but all are dynamically rendered
i've given the link of my repo, you can check the code at the high level to let me know why next is switching to dynamic routes
Github Link: https://github.com/devvMuhammad/admin-redeemx

2 Replies

Asian paper wasp
I am personally not too familiar with Next Auth, so I'm trying to answer this by logic.

Think of this, you are calling getServerSession() in the root layout. How can you get a user session in RUNTIME, when the page is generated on BUILD-TIME? So my understanding is this function makes the root layout dynamic. And since the root layout is dynamic, every page is now dynamic.

So the question is, do you really need to access the session on every page?
If not, may be NOT using the provider and only call getServerSession() in page.tsx that actually needs the user session may be a better idea.