Skip to content

Conversation

@jacekradko
Copy link
Member

@jacekradko jacekradko commented Jan 14, 2026

Summary

  • Adds a jscodeshift codemod that transforms ClerkProvider from wrapping <html> to being inside <body>
  • This is needed for Next.js 16 cache components support - when cacheComponents is enabled, ClerkProvider must be positioned inside <body> to avoid "Uncached data was accessed outside of <Suspense>" errors
  • Includes 7 test cases covering various layout patterns

What it does

Transforms layouts from:

<ClerkProvider>
  <html>
    <body>{children}</body>
  </html>
</ClerkProvider>

To:

<html>
  <body>
    <ClerkProvider>
      {children}
    </ClerkProvider>
  </body>
</html>

Test plan

  • All 7 codemod tests pass
  • All 167 upgrade package tests pass
  • Manual testing with npx @clerk/upgrade on a sample Next.js project

Related

Summary by CodeRabbit

  • New Features

    • Added an automated codemod to move ClerkProvider into the .
    • Upgrade tool now supports SDK/package-targeted codemods so only relevant transforms run.
  • Tests

    • Added fixtures, unit tests for the ClerkProvider transform, and integration tests for codemod runner filtering and behavior.
  • Documentation

    • Added an upgrade guide with before/after examples and usage notes for ClerkProvider placement.
  • Chores

    • Added a changeset announcing the codemod and minor version bump.

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

Add jscodeshift codemod that transforms ClerkProvider from wrapping
<html> to being inside <body> for Next.js 16 cache components support.

This codemod handles:
- Moving ClerkProvider inside body element
- Preserving all ClerkProvider props
- Handling layouts with multiple body children
- Handling layouts with head elements
@changeset-bot
Copy link

changeset-bot bot commented Jan 14, 2026

🦋 Changeset detected

Latest commit: de2f6f8

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

This PR includes changesets to release 1 package
Name Type
@clerk/upgrade Minor

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 Jan 14, 2026

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

1 Skipped Deployment
Project Deployment Review Updated (UTC)
clerk-js-sandbox Skipped Skipped Jan 16, 2026 7:55pm

Request Review

- Add transform-clerk-provider-inside-body to core-3 codemods list
- Add change document explaining the ClerkProvider positioning for
  Next.js 16 cache components support
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 14, 2026

📝 Walkthrough

Walkthrough

Adds a new codemod transform-clerk-provider-inside-body (parser = 'tsx') that moves ClerkProvider from wrapping <html> into the <body>. Adds unit test fixtures and a Vitest test for the transform, integration tests for codemod selection/execution, and documentation describing the change for Next.js 16 cache components. Registers the codemod in the Core 3 upgrade config, updates the runner to accept string/object codemod entries and filter codemods by package/SDK, and includes a changeset.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: adding a codemod that moves ClerkProvider from wrapping html to inside body, which is the core objective of this changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 14, 2026

Open in StackBlitz

@clerk/agent-toolkit

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

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

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

@clerk/expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

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

@clerk/upgrade

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

@clerk/vue

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

commit: de2f6f8

Codemods can now specify which SDKs they apply to using the packages
property. This matches the existing pattern used for change documents.

Example:
  codemods: [
    'transform-all',  // runs for all SDKs
    { name: 'transform-nextjs-only', packages: ['nextjs'] },
  ]

The ClerkProvider codemod now only runs for nextjs upgrades.
@panteliselef
Copy link
Contributor

🥇

…ider codemod

- Support aliased imports like `import { ClerkProvider as CP }`
- Handle multiple ClerkProviders by only transforming those wrapping <html>
- Simplify whitespace handling (rely on user's formatter)
- Add test fixtures for new edge cases
@jacekradko jacekradko merged commit 145b8bc into main Jan 16, 2026
40 checks passed
@jacekradko jacekradko deleted the feat/codemod-clerk-provider-inside-body branch January 16, 2026 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants