You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ClerkProvider + auth + everything not compatible with next PPR (next 14) #2501
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.
The Partial Prerendering feature is marked as highly experimental:
Warning: Partial Prerendering is an experimental feature and is currently not suitable for production environments.
It also has these gotchas:
Partial Prerendering does not yet apply to client-side navigations. We are actively working on this.
There's a good chance that things are not working because something isn't implemented/right yet in Next.js itself. It's also possible that we'll need to update something on our end. Until this feature is in beta or soon to be released we'll however not spend time on this as things aren't settled just yet.
I'd encourage you to open an issue on Next.js and see what the root cause of the error might be. Thanks!
Thanks for looking into this. While I see, that this feature is still experimental, I don't agree with your statement that this lies on nexts side.
React throws an error when server features are used (headers, cookies) that is used to determine if a component needs to opt out of static rendering (and will be partially prerendered). Since your implementation uses headers() within a try-catch blog:
Prerendering /_not-found needs to partially bail out because something dynamic was used. React throws a special object to indicate where we need to bail out but it was caught by a try/catch or a Promise was not awaited. These special objects should not be caught by your own try/catch. Learn more: https://nextjs.org/docs/messages/ppr-caught-error
⚠ The following error was thrown during build, and may help identify the source of the issue:
⨯ Error: Clerk: auth() and currentUser() are only supported in App Router (/app directory).
If you're using /pages, try getAuth() instead.Original error: Error: This page needs to bail out of prerendering at this point because it used headers. React throws this special object to indicate where. It should not be caught by your own try/catch. Learn more: https://nextjs.org/docs/messages/ppr-caught-error
I see that this feature is still experimental, but I am certain it will make it to prod. and also certain that the implementation will be similar to what it is right now, since they don't want to introduce new apis for this.
A simple solution would be to determine and integrate the new error message into the rethrow block of buildRequestLike and simply rethrow this error as well.
It is indeed annoying, since I would love to use PPR right now and clerk is the only thing holding me back.
Should be a simple fix. Please reopen. Happy to help :)
Okay, if you think that change alone would make it work, then please put up a PR. As I said we have other priorities right now but happy to look at a PR.
You can (quickly) test this yourself locally:
Remove your .next folder
Go into node_modules/@clerk/nextjs/dist/esm/server/utils.js and make your change there
Activity
LekoArts commentedon Jan 8, 2024
Hi, thanks for the issue!
The Partial Prerendering feature is marked as highly experimental:
It also has these gotchas:
There's a good chance that things are not working because something isn't implemented/right yet in Next.js itself. It's also possible that we'll need to update something on our end. Until this feature is in beta or soon to be released we'll however not spend time on this as things aren't settled just yet.
I'd encourage you to open an issue on Next.js and see what the root cause of the error might be. Thanks!
juliuslipp commentedon Jan 8, 2024
Hey @LekoArts,
Thanks for looking into this. While I see, that this feature is still experimental, I don't agree with your statement that this lies on nexts side.
React throws an error when server features are used (headers, cookies) that is used to determine if a component needs to opt out of static rendering (and will be partially prerendered). Since your implementation uses headers() within a try-catch blog:
I see that this feature is still experimental, but I am certain it will make it to prod. and also certain that the implementation will be similar to what it is right now, since they don't want to introduce new apis for this.
Here is the matching lines of code:
https://github.com/clerk/javascript/blob/main/packages/nextjs/src/app-router/server/utils.ts#L4C1-L21C3
A simple solution would be to determine and integrate the new error message into the rethrow block of buildRequestLike and simply rethrow this error as well.
It is indeed annoying, since I would love to use PPR right now and clerk is the only thing holding me back.
Should be a simple fix. Please reopen. Happy to help :)
LekoArts commentedon Jan 9, 2024
Okay, if you think that change alone would make it work, then please put up a PR. As I said we have other priorities right now but happy to look at a PR.
You can (quickly) test this yourself locally:
.nextfoldernode_modules/@clerk/nextjs/dist/esm/server/utils.jsand make your change therejuliuslipp commentedon Jan 9, 2024
hey @LekoArts,
Just created a PR. Tested it and fixes the issue :) #2518
Do you roughly know when I can expect it to work with the npm package?
clerk-cookie commentedon Jan 12, 2025
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.