Skip to content

Conversation

@jacekradko
Copy link
Member

@jacekradko jacekradko commented Jan 21, 2026

Summary

Fixes: USER-4231

This PR removes the clerkJSVariant: 'headless' option and replaces it with a new prefetchUI prop that controls whether the @clerk/ui script is prefetched.

Changes

  • Removed: clerkJSVariant: 'headless' option from all SDK packages
  • Added: prefetchUI prop (boolean | undefined) to control UI bundle prefetching
    • prefetchUI={false} - Skip prefetching the UI bundle (for custom UIs using Control Components)
    • prefetchUI omitted or undefined - Prefetch UI normally (default behavior)
  • Renamed: shouldLoadClerkUishouldPrefetchClerkUi helper function
  • Updated: Environment variable from CLERK_UI_DISABLED to CLERK_PREFETCH_UI_DISABLED

Usage

// Disable UI prefetching (e.g., when using Control Components for custom UI)
<ClerkProvider prefetchUI={false}>
  {children}
</ClerkProvider>

// Or via environment variable
NEXT_PUBLIC_CLERK_PREFETCH_UI_DISABLED=true

Packages Updated

  • @clerk/shared
  • @clerk/react
  • @clerk/nextjs
  • @clerk/vue
  • @clerk/astro
  • @clerk/react-router
  • @clerk/tanstack-react-start
  • @clerk/express

Checklist

  • pnpm build passes
  • Updated integration tests
  • Updated integration templates

Summary by CodeRabbit

  • New Features

    • Added prefetchUI option and CLERK_PREFETCH_UI_DISABLED env var to control whether Clerk UI is prefetched.
  • Breaking Changes

    • Removed the headless variant and replaced clerkJSVariant with the boolean prefetchUI configuration.
  • Improvements

    • Unified conditional UI prefetching across frameworks, updated exports and tests, and added an integration test to verify disabling prefetch.

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

nikosdouvlis and others added 8 commits January 9, 2026 13:15
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.
…ition

The headless variant is no longer needed now that UI components have been
moved to @clerk/ui. The browser builds are now identical in size.

Changes:
- Add `react-native` export condition in package.json for Expo/RN
- Rename `clerkHeadless` build to `clerkNative` (no chunk splitting)
- Remove `clerkHeadlessBrowser` build (identical to regular browser)
- Update Expo to import from `@clerk/clerk-js` instead of `/headless`
- Deprecate `clerkJSVariant` option (now ignored)
- Delete headless source files and export directory

BREAKING CHANGE: `@clerk/clerk-js/headless` import path removed.
Expo/React Native users should import from `@clerk/clerk-js` directly.
@changeset-bot
Copy link

changeset-bot bot commented Jan 21, 2026

🦋 Changeset detected

Latest commit: 05b569c

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 21, 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 22, 2026 4:54am

Request Review

….com:clerk/javascript into jrad/remove-headless-variant
clerkJSVariant is still used to control whether @clerk/ui loads.
The option just no longer affects the clerk-js URL since the
separate headless build has been removed.
Replace the clerkJSVariant: 'headless' pattern with a cleaner ui prop API:
- ui: false - Skip loading @clerk/ui (for custom UIs)
- ui: { version?, url? } - Load UI with specific version/URL
- ui: undefined (default) - Load UI normally

Also adds shouldLoadClerkUi() helper function to shared package.

Breaking change: clerkJSVariant is removed in favor of ui prop.
@jacekradko jacekradko changed the title [DO NOT MERGE] feat(clerk-js): remove headless variant feat(clerk-js): remove headless variant, add ui prop Jan 21, 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.

3 participants