how to get (only get) cookies?
Unanswered
Carpenter wasp posted this in #help-forum
Carpenter waspOP
import { cookies } from 'next/headers' need server side, we only get cookies not set or delete why must in server side?6 Replies
@Carpenter wasp `import { cookies } from 'next/headers'` need server side, we only get cookies not set or delete why must in server side?
All next/headers methods are server side. To read cookies on the client, simply read from
document.cookieCarpenter waspOP
ok done
@ᴉuɐpɹɐɐ can you explain the question more?
Carpenter waspOP
i just want to get cookies value in client side, and i just read next js docs and wondering why we need to use server side if just want to get (only get, not set or delete) cookies
@Carpenter wasp i just want to get cookies value in client side, and i just read next js docs and wondering why we need to use server side if just want to get (only get, not set or delete) cookies
theres is no function by Next.js to get cookies value in client side. You can try joulev's way but Next.js recommends getting it from the server via cookies() and passing it to client component withnprops.
this is because some cookies can be httpOnly and may not been able to be read in the client