Next.js 15 canary with experimental PPR + dynamicIO issue calling headers()
Opened this issue · 0 comments
Jussinevavuori commented
Preliminary Checks
-
I have reviewed the documentation: https://clerk.com/docs
-
I have searched for existing issues: https://github.com/clerk/javascript/issues
-
I have not already reached out to Clerk support via email or Discord (if you have, no need to open an issue here)
-
This issue is not a question, general help request, or anything other than a bug report directly related to Clerk. Please ask questions in our Discord community: https://clerk.com/discord.
Reproduction
https://github.com/Jussinevavuori/clerk-next15-ppr-dynamicio-headers-issue
Publishable key
pk_test_ZnJlc2gtcmFtLTkxLmNsZXJrLmFjY291bnRzLmRldiQ
Description
Steps to reproduce:
- Clone reproduction repo.
- Install dependencies with
bun install
. - Copy
.env.example
as.env
and set up the required Clerk.env
variables. - Run with
bun dev
.
Expected behavior:
Should not cause any errors.
Actual behavior:
Causes below error.
⨯ unhandledRejection: Error: Clerk: auth() and currentUser() are only supported in App Router (/app directory).
If you're using /pages, try getAuth() instead.
Original error: Error: During prerendering, `headers()` rejects when the prerender is complete. Typically these errors are handled by React but if you move `headers()` to a different context by using `setTimeout`, `unstable_after`, or similar functions you may observe this error and you should handle it in that context.
at buildRequestLike (turbopack://[project]/node_modules/@clerk/nextjs/src/app-router/server/utils.ts:35:10)
at async getDynamicClerkState2 (turbopack://[project]/node_modules/@clerk/nextjs/src/app-router/server/ClerkProvider.tsx:17:18)
33 | }
34 |
> 35 | throw new Error(
| ^
36 | `Clerk: auth() and currentUser() are only supported in App Router (/app directory).\nIf you're using /pages, try getAuth() instead.\nOriginal error: ${e}`,
37 | );
38 | }
Environment
System:
OS: macOS 15.1
CPU: (10) arm64 Apple M1 Pro
Memory: 201.53 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.20.2 - ~/.nvm/versions/node/v18.20.2/bin/node
Yarn: 1.22.22 - ~/.nvm/versions/node/v18.20.2/bin/yarn
npm: 10.5.0 - ~/.nvm/versions/node/v18.20.2/bin/npm
pnpm: 9.0.1 - ~/.nvm/versions/node/v18.20.2/bin/pnpm
bun: 1.1.32 - ~/.bun/bin/bun
Watchman: 2024.10.28.00 - /opt/homebrew/bin/watchman
Browsers:
Chrome: 130.0.6723.92
Safari: 18.1