Next.js Discord

Discord Forum

Can you set a cookie in a client component?

Unanswered
Florian posted this in #help-forum
Open in Discord
I can use js-cookie to read cookies in a client component. When I call set, however, the cookie doesn't seem to be set.

I saw another code base where they did that tho. I didn't run the code but I'm wondering if it's possible to use Cookie.set in a client component.

8 Replies

@Florian what I do is just have a few server action helpers
Then just call them from client components
Also love your yt channel, I have seen a few vids from it
@Arinji <@495665932400853003> what I do is just have a few server action helpers
Yea, that's pretty smart. I would still like to know if it's possible to set a cookie from the client (to avoid an unnecessary detour over my server).

Thank you for the compliment!
@Arinji I love the gamified style of your website