You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Every page using getServerSideProps was wrapped with withPageAuthRequired, which from my understanding would populate this 'user' property in the pageProps shown above. This would make the 'user' object immediately available on first-render with pages that use getServerSideProps.
In v4 this is obviously gone, and the V4_MIGRATION_GUIDE.md (nearly all of the links in this guide are broken) points towards this in EXAMPLES.md:
... it won't work because this file cannot be asynchronous. The same goes for when I attempt aynthing like it my Layout files. (Here in the Next.js docs you see no async in any of the layout files or _app.tsx)
I am clueless how else I can pass an initial user from the server. I need this back so users do not see a 'flash' of empty content until the useUser() hook has retrieved the user.
Describe the ideal solution
Get the same functionality from v3 back in v4's for apps with Page Router
Alternatives and current workarounds
The only thing I could think of is having to add this to all of our pages with getSeverSideProps:
If you would like to pass an initial user during server rendering to be available to the useUser() hook, you can wrap your components with the new (see example).
could you please explain in the documentation what this means "If you would like to pass an initial user during server rendering to be available to the useUser() hook"
starting from what goal a developer is trying to achieve? "if you want to achieve X then do Y..."
@wjessup the way it used to work is that every page with getServerSideProps would add a 'user' object to the page props, making it available on first render.
Additionally if somewhere in the page or app's tree the useUser() hook is used, the page props user object would pre-populate the useUser()'s value
Checklist
Describe the problem you'd like to have solved
In v3 I used to have this in my Next.js app with Pages router, in the file src/pages/_app.tsx:
Every page using getServerSideProps was wrapped with withPageAuthRequired, which from my understanding would populate this 'user' property in the pageProps shown above. This would make the 'user' object immediately available on first-render with pages that use getServerSideProps.
In v4 this is obviously gone, and the V4_MIGRATION_GUIDE.md (nearly all of the links in this guide are broken) points towards this in EXAMPLES.md:
However, when I do what the example suggests in a _app.tsx file like this...:
... it won't work because this file cannot be asynchronous. The same goes for when I attempt aynthing like it my Layout files. (Here in the Next.js docs you see no
async
in any of the layout files or _app.tsx)I am clueless how else I can pass an initial user from the server. I need this back so users do not see a 'flash' of empty content until the useUser() hook has retrieved the user.
Describe the ideal solution
Get the same functionality from v3 back in v4's for apps with Page Router
Alternatives and current workarounds
The only thing I could think of is having to add this to all of our pages with getSeverSideProps:
But this does populate the the user returned by the
useUser()
hook...Additional context
No response
The text was updated successfully, but these errors were encountered: