Next.js Discord

Discord Forum

use next/headers in nextjs page router

Unanswered
Transvaal lion posted this in #help-forum
Open in Discord
Avatar
Transvaal lionOP
I'm curios as what is the alternative of extracting cookie from the headers fn in page router nextjs? i'm trying to apply this config in my app https://nextjs.org/docs/app/api-reference/functions/headers but unfortunately they have only an example for app router

10 Replies

Avatar
Transvaal lionOP
bump bump
Avatar
Asian paper wasp
So you want to access cookies in App Router, is that what you are asking for?

If yes, https://nextjs.org/docs/app/api-reference/functions/cookies
Avatar
Transvaal lionOP
nope, i'm trying to find a way to access cookies in the page router
Avatar
averydelusionalperson
Avatar
Short mackerel
Do you have Client and Server Rendering?
Avatar
Transvaal lionOP
dope, will check this out!
well i guess that via page router, i would have to hydrate them on each page. but gonna check link above from @averydelusionalperson
Avatar
averydelusionalperson
@Transvaal lion Consider closing the thread if your problem has been solved
Avatar
Transvaal lionOP
will do, still trying to find a solution for the hydrating the cookie with page router like in app router for one lib that i'm using ( https://wagmi.sh/react/guides/ssr#_2-hydrate-the-cookie )
Avatar
averydelusionalperson
Sure