nextjs-subscription-payments: DynamicServerError: Dynamic server usage: cookies when trying to deploy
I’m seeing this error https://github.com/vercel/next.js/issues/49373 when trying to deploy the example via Vercel.
Here’s an excerpt from the build logs.
- warn Entire page /signin deopted into client-side rendering. https://nextjs.org/docs/messages/deopted-into-client-rendering /signin
--
22:43:28.079 | DynamicServerError: Dynamic server usage: cookies
22:43:28.079 | at staticGenerationBailout (/vercel/path0/.next/server/chunks/883.js:11341:21)
22:43:28.080 | at Object.cookies (/vercel/path0/.next/server/chunks/883.js:11231:62)
22:43:28.080 | at NextServerComponentAuthStorageAdapter.getCookie (/vercel/path0/.next/server/chunks/913.js:199:42)
22:43:28.080 | at NextServerComponentAuthStorageAdapter.getItem (/vercel/path0/.next/server/chunks/913.js:571:28)
22:43:28.080 | at /vercel/path0/.next/server/chunks/883.js:3008:37
22:43:28.080 | at Generator.next (<anonymous>)
22:43:28.080 | at /vercel/path0/.next/server/chunks/883.js:2916:71
22:43:28.080 | at new Promise (<anonymous>)
22:43:28.080 | at __awaiter (/vercel/path0/.next/server/chunks/883.js:2898:12)
22:43:28.081 | at getItemAsync (/vercel/path0/.next/server/chunks/883.js:3007:38) {
22:43:28.081 | digest: 'DYNAMIC_SERVER_USAGE'
22:43:28.081 | }
22:43:28.081 | Error: DynamicServerError: Dynamic server usage: cookies
22:43:28.081 | at staticGenerationBailout (/vercel/path0/.next/server/chunks/883.js:11341:21)
22:43:28.083 | at Object.cookies (/vercel/path0/.next/server/chunks/883.js:11231:62)
22:43:28.083 | at NextServerComponentAuthStorageAdapter.getCookie (/vercel/path0/.next/server/chunks/913.js:199:42)
22:43:28.084 | at NextServerComponentAuthStorageAdapter.getItem (/vercel/path0/.next/server/chunks/913.js:571:28)
22:43:28.084 | at /vercel/path0/.next/server/chunks/883.js:3008:37
22:43:28.084 | at Generator.next (<anonymous>)
22:43:28.084 | at /vercel/path0/.next/server/chunks/883.js:2916:71
22:43:28.084 | at new Promise (<anonymous>)
22:43:28.084 | at __awaiter (/vercel/path0/.next/server/chunks/883.js:2898:12)
22:43:28.084 | at getItemAsync (/vercel/path0/.next/server/chunks/883.js:3007:38) {
22:43:28.084 | digest: 'DYNAMIC_SERVER_USAGE'
tried this with next@13.4.5 as well
Any way to fix this?
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 6
- Comments: 22
I don’t like the export const revalidate =0; solution, I don’t want my entire app to build and operate like that.
I fixed it by add “use server” to the supabase-server.ts functions (getSession, getUserDetails, getSubscription, getActiveProductsWithPrices). The createServerSupabaseClient was giving me issues with the {cookies} it passes via server component.
Here’s what a function looked like:
export async function getSession() { ‘use server’ const supabase = createServerSupabaseClient(); try { const { data: { session } } = await supabase.auth.getSession(); return session; } catch (error) { console.error(‘Error:’, error); return null; } }
Here is the Next JS page that helped me solve:
https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions
I fixed it by adding
export const revalidate = 0;to thelayout.tsxSame error for me as well when using cookies in the latest supabase auth helpers.
No issues with previous Nextjs version (pre 13.4) and older supabase auth helpers.
Dear God…
Same problem here!
Any news here guys?
Same error on my side ((
I get this too, it looks like it never builds any api route pages, for me anyway!
I’ve tried adding
export const dynamic = ‘force-dynamic’; export const revalidate = 0;
to those pages but it has no effect 😦
This #223 fixed the error for me.
I’ve tried adding ‘use server’ to every function supabase is related to, and still nothing works.
removing the supabase cli fixed it for me.