moshest / next-client-cookies

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

Error `cookies() expects to have requestAsyncStorage, none available` using `useCookies` #11

Closed pzxmsry closed 11 months ago

pzxmsry commented 12 months ago

Whenever I wrap my application in CookiesProvider imported from "next-client-cookies/server", I receive this error. I was not calling useCookies or cookies anywhere, so, what might be the problem?

moshest commented 12 months ago

You should place the CookiesProvider within the root layout.tsx file. This file must be a server component.

Also, what's your Next.js version?

pzxmsry commented 11 months ago

My Next.js version is 14.0.2, and you were right, when I placed it in a separate providers server component, everything worked. Thank you!