#How do you fetch and share authedUser throughout the app?
18 messages · Page 1 of 1 (latest)
🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord
🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize
✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)
you can set session in cookies
https://nextjs.org/docs/app/building-your-application/authentication
I am using old pages router. Is this still relevant?
Maybe it is just better to fetch authedUser on client side?
@vast linden How do you consume the user data on your pages?
I take it out from the pageProps in the _app.tsx and then share it with context. But with this approach I have to fetch authedUser in every single route using getServerSideProps, to make it available under pageProps inside _app.tsx. Which is not ideal, because it does not let me use static generation
The reason I need it on every page is because I need user info in layout to show in the navigation bar
well, your approach is not correct
you want to show user data in the navigation bar but you still want SSG
it doesn't make sense
static generation happens in build time and at that moment you don't know auth user
yeah. I know it is not correct, that's why I am asking which would be the best approach, to fetch authed user on client side? What would you recommend
from your previous messages, I guess you are on the page router, right?
You can fetch user data from the client side and store it in your global state
Thanks
Why don't you wrap your all routes(pages) by a layout component?
I do. but I could not fetch it inside layout since I was using SSR