SupabaseS
Supabase2y ago
kit

Error when navigating to dynamic route in Next.js

I am learning Supabase by creating a Next.js projext.

I have auth full working (using cookies, not local storage), saving users to by DB in the users table.

I have a Posts table, with the route posts/[postId] as the show page for the post.

On the page.tsx for posts[postid], I am destructing the params so I can know what post I need to get from supabase, but I keep seeing this error in the console.

Error: Invariant: cookies() expects to have requestAsyncStorage, none available.
    at Object.cookies (webpack-internal:///(rsc)/./node_modules/next/dist/client/components/headers.js:50:15)
    at NextServerComponentAuthStorageAdapter.getCookie (webpack-internal:///(rsc)/./node_modules/@supabase/auth-helpers-nextjs/dist/index.js:193:42)
    at NextServerComponentAuthStorageAdapter.getItem (webpack-internal:///(rsc)/./node_modules/@supabase/auth-helpers-shared/dist/index.mjs:299:28)
    at getItemAsync (webpack-internal:///(rsc)/./node_modules/@supabase/gotrue-js/dist/module/lib/helpers.js:107:33)
    at SupabaseAuthClient._recoverAndRefresh (webpack-internal:///(rsc)/./node_modules/@supabase/gotrue-js/dist/module/GoTrueClient.js:1585:100)
    at SupabaseAuthClient._initialize (webpack-internal:///(rsc)/./node_modules/@supabase/gotrue-js/dist/module/GoTrueClient.js:187:24)
    at eval (webpack-internal:///(rsc)/./node_modules/@supabase/gotrue-js/dist/module/GoTrueClient.js:140:35)
(node:34822) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
webpack-internal:///(rsc)/./node_modules/next/dist/client/components/headers.js:50
        throw new Error("Invariant: cookies() expects to have requestAsyncStorage, none available.");
              ^
`
Supabase gets the correct post info, and the page renders correctly, but I'm not sure why I'm getting this error.
Any help would be greatly appriciated.
Was this page helpful?