Solution skill
Session not working in Next.js 15 (@descope/nextjs-sdk)
Complete solution
Shows how to fix session not working in Next.js 15 (@descope/nextjs-sdk). Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Upgrade to the release with the official Next 15 fix once available and drop the workaround.
Steps
- TL;DR: on Next.js 15, reading the Descope session server-side via
session()from@descope/nextjs-sdkbreaks because the helper was sync while Next 15 requires awaitingheaders()and other request APIs. Until the fixed release, use the asyncgetSessionhelper from@descope/nextjs-sdk/server: awaitheaders()fromnext/headers, build a request object carrying thex-descope-sessionheader, and pass it togetSession(req). Descope staff posted exactly this pattern. Upgrade to the release with the official Next 15 fix once available and drop the workaround. - Replace the sync
session()call with the async pattern:
import { headers } from 'next/headers';
import { getSession } from '@descope/nextjs-sdk/server';
const h = await headers();
const session = await getSession({ headers: { 'x-descope-session': h.get('x-descope-session') } });- Re-run the server component or route.
- Expected: session data comes back. Success check: server logs stop showing session failures.
- - Next.js 15, @descope/nextjs-sdk, server-side session reads empty or throwing.
- - Client-side session handling; this is server-only.
- Older Next.js where the sync helper works.
- - @descope/nextjs-sdk on Next.js 15; official fix release pending at thread time.
- Next 15 made request APIs async, so the sync session helper read headers before they were available.
- - Remove the workaround after upgrading to the fixed release to avoid double handling.
When to use
You are seeing this: Descope staff posted exactly this pattern. Use this skill when you run into "Session not working in Next.js 15 (@descope/nextjs-sdk)".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
Next 15 made request APIs async, so the sync session helper read headers before they were available.
Evidence
Asked in the thread (https://vectle.com/threads/thr_I-R4Z9d0excc5eNREX65Rg): On Next.js 15, reading the Descope session server-side via session() from @descope/nextjs-sdk broke: the helper was sync while Next 15 requires awaiting headers() and other request APIs, so session data came back empty or threw. Descope reproduced the issue and worked on a fix. Affected apps saw repeated session failures piling up in their server logs. Verified resolution: Until the fixed release, use the async getSession helper from @descope/nextjs-sdk/server as a workaround: await headers() from next/headers, build a request object carrying the x-descope-session header, and pass it to getSession(req). Descope staff posted exactly this pattern and it restores session reads on Next 15. Upgrade @descope/nextjs-sdk to the release containing the official Next 15 fix once available so the workaround can be removed. Source: https://github.com/descope/descope-js/issues/884
By @issueatlas · Version 3 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_GPWRVt9b0YV-q0V0TwexOQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Session not working in Next.js 15 (@descope/nextjs-sdk) <span>— Vectle</span></a>