Skip to content

Conversation

@jacekradko
Copy link
Member

@jacekradko jacekradko commented Dec 27, 2025

Description

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • Bug Fixes
    • Fixed prerendering errors when using auth() with Next.js 16 Cache Components. Enhanced compatibility handling ensures stable operation across Next.js 16 and earlier versions while maintaining full backward compatibility.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link

changeset-bot bot commented Dec 27, 2025

🦋 Changeset detected

Latest commit: eba08cd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@clerk/nextjs Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Dec 27, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Dec 28, 2025 3:45am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 27, 2025

📝 Walkthrough

Walkthrough

A runtime guard is added to the auth() function that dynamically imports and invokes Next.js 16's connection() function to opt out of prerendering. The guard executes before request building and includes error handling for prerendering bailout scenarios. For Next.js versions that lack the connection() function, execution proceeds without invoking it. A changeset documents this patch release for addressing prerendering errors with auth() in Next.js 16. No changes to exported function signatures or public APIs are introduced.

Pre-merge checks

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'feat(nextjs): Allow PPR with auth()' is related to the main change but uses unclear terminology. PPR is undefined jargon, and the title doesn't clearly describe what the change does. Consider replacing 'Allow PPR with auth()' with a clearer description like 'Fix prerendering errors in auth() with Next.js 16' to better communicate the actual change to reviewers.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

📜 Recent review details

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 82d6703 and eba08cd.

📒 Files selected for processing (2)
  • .changeset/silent-streets-rest.md
  • packages/nextjs/src/app-router/server/auth.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/nextjs/src/app-router/server/auth.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (26)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (machine, chrome, RQ)
  • GitHub Check: Integration Tests (billing, chrome, RQ)
  • GitHub Check: Integration Tests (machine, chrome)
  • GitHub Check: Integration Tests (quickstart, chrome, 16)
  • GitHub Check: Integration Tests (quickstart, chrome, 15)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 16)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 16, RQ)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (custom, chrome)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (handshake:staging, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Integration Tests (sessions:staging, chrome)
  • GitHub Check: Integration Tests (handshake, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (1)
.changeset/silent-streets-rest.md (1)

1-6: Changeset format and message are clear.

The changeset file is correctly formatted and the patch-level version bump is appropriate for this bug fix. The description accurately captures the high-level change (fixing prerendering errors with auth() and Next.js 16 Cache Components).

However, the actual implementation file (packages/nextjs/src/app-router/server/auth.ts) is not provided for review. To complete the assessment, please ensure that:

  1. The dynamic import of connection() is properly implemented with robust error handling.
  2. Prerendering bailout errors are correctly identified and re-thrown for Next.js to handle.
  3. Graceful fallback for older Next.js versions (where connection() is absent) works correctly.
  4. The change executes before request building to properly signal runtime data requirements.

Without reviewing the implementation file, I cannot assess code quality, error handling robustness, or edge cases. Please share packages/nextjs/src/app-router/server/auth.ts for a complete review of the implementation details.


Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 27, 2025

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@7530

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@7530

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@7530

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@7530

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@7530

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@7530

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@7530

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@7530

@clerk/express

npm i https://pkg.pr.new/@clerk/express@7530

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@7530

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@7530

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@7530

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@7530

@clerk/react

npm i https://pkg.pr.new/@clerk/react@7530

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@7530

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@7530

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@7530

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@7530

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@7530

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@7530

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@7530

commit: eba08cd

… Components

Call connection() in auth() before accessing headers() to explicitly signal that
the route requires runtime data and cannot be prerendered. This fixes build errors
when cacheComponents is enabled in next.config.ts.

The fix:
- Adds connection() call at the start of auth() function
- Gracefully handles older Next.js versions where connection() doesn't exist
- Properly re-throws prerendering bailout errors for Next.js to handle

Fixes prerendering errors like:
'During prerendering, headers() rejects when the prerender is complete'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants