Next.js caching and revalidating problem
Unanswered
Abyssinian posted this in #help-forum
Original message was deleted.
18 Replies
Using cookies() will mark the entire route into dynamic rendering and i dont think there is a workaround that. IG it might be due to the fact that cookies are returned with the request for the page itself.
but then what the hell should i do 😅
any other ways recommended instead of using cookies?
to save the auth token?
Because that way i cant cache.
From that comes, I cant revalidate data
and thats making my app worse
I dont know why i have never pondered over this but i would assume (and maybe someone else can correct me) but the best way would be to either use a context provider to pass the session around OR use a server action/route handler to fetch the session for you.
@Clown I dont know why i have never pondered over this but i would assume (and maybe someone else can correct me) but the best way would be to either use a context provider to pass the session around OR use a server action/route handler to fetch the session for you.
Abyssinian
with server action or route handler same thing would happen i guess
if i use cookies when fetching
context could be great
Abyssinian
vercel AI
i dont understand the middleware express-session part
Asian black bear
What happens if you make it into a component and do all the logic in there, and then wrap it in a Suspense where you use it? Because thats how it will work with https://nextjs.org/docs/app/api-reference/next-config-js/partial-prerendering
@Asian black bear What happens if you make it into a component and do all the logic in there, and then wrap it in a Suspense where you use it? Because thats how it will work with https://nextjs.org/docs/app/api-reference/next-config-js/partial-prerendering
Abyssinian
still the component where i use it will be dynamic
inside the suspense.