© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•3y ago•
9 replies
dandis

RequestAsyncStorage error with NextJS 14 and @supabase/ssr

This is my server client from
@supabase/ssr
@supabase/ssr
:
import { Database } from '@/types';
import { createServerClient, type CookieOptions } from '@supabase/ssr';
import { cookies } from 'next/headers';

const cookieStore = cookies();

export const serverSupabase = createServerClient<Database>(
    process.env.NEXT_PUBLIC_SUPABASE_URL!,
    process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
    {
        cookies: {
            get(name: string) {
                return cookieStore.get(name)?.value;
            },
            set(name: string, value: string, options: CookieOptions) {
                cookieStore.set({ name, value, ...options });
            },
            remove(name: string, options: CookieOptions) {
                cookieStore.delete({ name, ...options });
            },
        },
    }
);
import { Database } from '@/types';
import { createServerClient, type CookieOptions } from '@supabase/ssr';
import { cookies } from 'next/headers';

const cookieStore = cookies();

export const serverSupabase = createServerClient<Database>(
    process.env.NEXT_PUBLIC_SUPABASE_URL!,
    process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
    {
        cookies: {
            get(name: string) {
                return cookieStore.get(name)?.value;
            },
            set(name: string, value: string, options: CookieOptions) {
                cookieStore.set({ name, value, ...options });
            },
            remove(name: string, options: CookieOptions) {
                cookieStore.delete({ name, ...options });
            },
        },
    }
);


I am importing it into route handlers, middleware and RSC.
Using NextJS 14.0.1, and I get this error when trying to build:
Error: Invariant: cookies() expects to have requestAsyncStorage, none available.
Error: Invariant: cookies() expects to have requestAsyncStorage, none available.

Error: Failed to collect page data for /auth/sign-out
Error: Failed to collect page data for /auth/sign-out
, same goes for collecting page data for others that import the supabase server client.
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

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Nextjs Supabase Error
SupabaseSSupabase / help-and-questions
3y ago
NextJs Supabase SSR rate limit with cache wrapper...
SupabaseSSupabase / help-and-questions
3y ago
@supabase/ssr signout nextjs app-router
SupabaseSSupabase / help-and-questions
3y ago
session with @supabase/ssr
SupabaseSSupabase / help-and-questions
3y ago