Next.js Discord

Discord Forum

User data passing in navbar problem

Answered
Sajid posted this in #help-forum
Open in Discord
I added custom authentication in Next.js . When i want to send user data to the Navbar component getCurrentUser() function then the most of the pages converted to the dynamic page.. As i know the best practice is to keep the pages to static. Please help. Thank you in advance.
Answered by B33fb0n3
when it would be static, it would mean, that the page is created during build time and that would mean, that all people would get the same version. However, that would be horrible, when looking from the auth perspective. So you need to have them dynamic.

In next16 cache components are introduced, that build a static shell and only parts of the page are dynamic and those parts can also be cached even if its user related content (depending on user). You might want to have a look at that
View full answer

6 Replies

@Sajid I added custom authentication in Next.js . When i want to send user data to the Navbar component getCurrentUser() function then the most of the pages converted to the dynamic page.. As i know the best practice is to keep the pages to static. Please help. Thank you in advance.
when it would be static, it would mean, that the page is created during build time and that would mean, that all people would get the same version. However, that would be horrible, when looking from the auth perspective. So you need to have them dynamic.

In next16 cache components are introduced, that build a static shell and only parts of the page are dynamic and those parts can also be cached even if its user related content (depending on user). You might want to have a look at that
Answer
@Sajid So won't it cause any performence issue?
When doing it it cache components correctly, it won’t cause performance issues
happy to help