moshest / next-client-cookies

SSR and client support for cookies in Next.js 13 (app directory)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cookies() expects to have requestAsyncStorage, none available.

Oolix opened this issue · comments

I'm not sure if my usage is incorrect or not but my error is following:

Collecting page data ...Error: Invariant: cookies() expects to have requestAsyncStorage, none available. at cookies (webpack-internal:///2491:50:15) at getCookies (webpack-internal:///9491:22:36) at eval (webpack-internal:///573:16:96) at 573 (C:\Users\Alex\Desktop\GitHub\Frontend\.next\server\app\Dashboard\page.js:1:262747) at __webpack_require__ (C:\Users\Alex\Desktop\GitHub\Frontend\.next\server\webpack-runtime.js:1:146) at eval (webpack-internal:///877:57:17)

Here's my code:

"use server"
...
import { getCookies } from 'next-client-cookies/server'

const Dashboard = async () => {

const cookies = getCookies();

const userData = JSON.parse(cookies.get('userData'));

...

return(
    ...
    )
} 

export default Dashboard;

@alexbmills5 from what I can see, this error is not related to this library and caused by calling cookies() from Next.js.

getCookies() is just a wrapper around cookies(). Can you try replace this call with Native cookies() and see if you still see this error?

Closing this until we receive more details.