Skip to content

Conversation

@nikosdouvlis
Copy link
Member

@nikosdouvlis nikosdouvlis commented Jan 9, 2026

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

  • New Features

    • Adds a configurable "headless" mode so only the core Clerk script is loaded and the UI script is omitted when enabled across Next.js, Astro, React, and Vue.
  • Tests

    • Added an integration test verifying headless behavior: core Clerk script injected, UI script skipped.
  • Chores

    • Added a small changeset placeholder for the release.

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

why:
when using clerkJSVariant='headless', applications only need control components and don't require the full UI bundle. loading the unnecessary @clerk/ui script adds overhead without providing value.

what changed:
- clerk-script.tsx: conditionally render clerk-ui script tag only when clerkJSVariant !== 'headless'
- integration template: read NEXT_PUBLIC_CLERK_JS_VARIANT env var and pass to ClerkProvider

users can now set NEXT_PUBLIC_CLERK_JS_VARIANT='headless' to skip loading the ~100KB @clerk/ui bundle when using only control components.
why:
when using clerkJSVariant='headless', applications only need control components and don't require the full UI bundle. loading the unnecessary @clerk/ui script adds overhead without providing value.

what changed:
- build-clerk-hotload-script: skip generating clerk-ui script tag when clerkJsVariant === 'headless'
- create-clerk-instance: getClerkUiEntryChunk returns undefined for headless variant to skip client-side hot-loading

users can now set clerkJSVariant='headless' to skip loading the ~100KB @clerk/ui bundle when using only control components.
why:
when using clerkJSVariant='headless', applications only need control components and don't require the full UI bundle. loading the unnecessary @clerk/ui script adds overhead without providing value.

what changed:
isomorphicClerk's getClerkUiEntryChunk method now returns undefined when clerkJSVariant === 'headless', skipping the loadClerkUiScript call entirely.

users can now set clerkJSVariant='headless' to skip loading the ~100KB @clerk/ui bundle when using only control components.
why:
when using clerkJSVariant='headless', applications only need control components and don't require the full UI bundle. loading the unnecessary @clerk/ui script adds overhead without providing value.

what changed:
clerkPlugin now checks if clerkJSVariant === 'headless' and skips the loadClerkUiScript call, resolving the clerkUiCtorPromise to undefined instead.

users can now set clerkJSVariant='headless' to skip loading the ~100KB @clerk/ui bundle when using only control components.
why:
verify that the headless variant correctly skips clerk-ui script injection across the full integration stack (env var → prop → script rendering).

what changed:
created headless-variant.test.ts that sets CLERK_JS_VARIANT='headless' and asserts clerk-ui script is absent while clerk-js script is present.
@changeset-bot
Copy link

changeset-bot bot commented Jan 9, 2026

🦋 Changeset detected

Latest commit: c6a734e

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

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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 9, 2026

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

Project Deployment Review Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Jan 29, 2026 2:48pm

Request Review

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 9, 2026

Open in StackBlitz

@clerk/agent-toolkit

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

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

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

@clerk/expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

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

@clerk/upgrade

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

@clerk/vue

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

commit: c6a734e

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 9, 2026

📝 Walkthrough

Walkthrough

Adds support for a clerkJSVariant value of "headless" across Next.js, Astro, React, and Vue integrations. When clerkJSVariant === 'headless', the Clerk UI constructor is not loaded or returned and the Clerk UI script is omitted, while the core Clerk JS script continues to be produced. Several internal functions and signatures were adjusted to allow undefined when the UI is skipped. An integration test was added to confirm the Clerk JS script is injected and the Clerk UI script is not present in headless mode.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.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 title clearly and concisely summarizes the main change: preventing clerk-ui loading when headless variants are used, which is the primary objective across all modified files.

✏️ 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.

Copy link
Member

@jacekradko jacekradko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

…-ui-if-headless-is-used

# Conflicts:
#	packages/nextjs/src/utils/clerk-script.tsx
@nikosdouvlis nikosdouvlis changed the title Skip loading clerk-ui when headless variants are used feat(*): Skip loading clerk-ui when headless variants are used Jan 29, 2026
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.

4 participants