© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•3y 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]
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.");
              ^
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.
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

How to get session on API route in Next.js
SupabaseSSupabase / help-and-questions
4y ago
Next.js force-dynamic for auth cookies?
SupabaseSSupabase / help-and-questions
2mo ago
Having trouble getting user in Next JS 14 route handler
SupabaseSSupabase / help-and-questions
3y ago
Getting user data on dynamic page with Next JS
SupabaseSSupabase / help-and-questions
4y ago