moshest / next-client-cookies

SSR and client support for cookies in Next.js 13 (app directory)
MIT License
136 stars 9 forks source link

Error: Cookies can only be modified in a Server Action or Route Handler. #19

Closed phpgng closed 3 months ago

phpgng commented 3 months ago

I try to set cookies inside "use server". But I got Error: Cookies can only be modified in a Server Action or Route Handler.

moshest commented 3 months ago

This is not the purpose of this library.

This library build to solve the issue of SSR when some client components can't access the cookies because they are pre-rendered on the server.

Please refer to the README, client components that rendered on the server are NOT equal to server-side components.