use next/headers in nextjs page router
Unanswered
Transvaal lion posted this in #help-forum
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
Transvaal lionOP
bump bump
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
If yes, https://nextjs.org/docs/app/api-reference/functions/cookies
Transvaal lionOP
nope, i'm trying to find a way to access cookies in the page router
@Transvaal lion nope, i'm trying to find a way to access cookies in the page router
Short mackerel
Do you have Client and Server Rendering?
@averydelusionalperson check this out: https://www.npmjs.com/package/cookies-next
Transvaal lionOP
dope, will check this out!
@Short mackerel Do you have Client and Server Rendering?
Transvaal lionOP
well i guess that via page router, i would have to hydrate them on each page. but gonna check link above from @averydelusionalperson
@Transvaal lion Consider closing the thread if your problem has been solved
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 )