cookies()
Answered
Southeastern blueberry bee posted this in #help-forum
Southeastern blueberry beeOP
hey
can i pass cookie value from server component to client component as props ?
can i pass cookie value from server component to client component as props ?
Answered by MikeTheTechLead
One little tidbit: Page generation becomes dynamic (as in per request) if you do.
Otherwise, if the cookie is NOT http-only, you can instead grab it out in the client component directly and make sure its only client rendered. This way you can keep the page statically rendered
Otherwise, if the cookie is NOT http-only, you can instead grab it out in the client component directly and make sure its only client rendered. This way you can keep the page statically rendered
9 Replies
hey, yes you can
@Southeastern blueberry bee what else do u need?
Southeastern blueberry beeOP
Nothing else thanks for your help
One little tidbit: Page generation becomes dynamic (as in per request) if you do.
Otherwise, if the cookie is NOT http-only, you can instead grab it out in the client component directly and make sure its only client rendered. This way you can keep the page statically rendered
Otherwise, if the cookie is NOT http-only, you can instead grab it out in the client component directly and make sure its only client rendered. This way you can keep the page statically rendered
Answer
he can also add
export const dynamic = 'force-static'
on top of his page and the page will be statically rendered. Btw: that wasnt his question 🙂But then the cookies function will become empty 🙂
What i was getting at was that getting cookies on the server to then pass it to a client component seems a little hacky / wrong to me, and seems to be a way to circumvent a http-only cookie, which is supposed to NOT be accessible in javascript because it can be exploited
What i was getting at was that getting cookies on the server to then pass it to a client component seems a little hacky / wrong to me, and seems to be a way to circumvent a http-only cookie, which is supposed to NOT be accessible in javascript because it can be exploited
But in this case im thinking on stuff like jwt / session cookie or similar
Southeastern blueberry beeOP
The cookie is not http-only so I will access it client side instead of passing props down to client thanks for the clarification