-
Notifications
You must be signed in to change notification settings - Fork 431
feat(clerk-js): remove headless variant #7629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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 detectedLatest commit: c2824b6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 20 packages
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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
….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.
packages/upgrade/src/versions/core-3/changes/clerk-ui-url-renamed.md
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! Few minor things:
clerkUIVersion in isomorphicClerk.ts
The old code pulled this.options.ui?.version into clerkUiVersion when calling loadClerkUiScript. Now it just spreads this.options, but there's no clerkUIVersion on IsomorphicClerkOptions, so the version never actually makes it to the script URL builder. Was this dead code before, or do we need to add the field?
clerkUiCtor casing
We renamed clerkUiUrl → clerkUIUrl to match clerkJSUrl, but clerkUiCtor still has the old casing. Should probably be clerkUICtor while we're at it
Env var naming
CLERK_PREFETCH_UI_DISABLED=true mapping to prefetchUI: false is a double negation. Can we just use CLERK_PREFETCH_UI=false instead? Same for the framework-prefixed variants (NEXT_PUBLIC_CLERK_PREFETCH_UI, PUBLIC_CLERK_PREFETCH_UI, etc.)
Rename internal functions to use consistent ClerkJS casing: - loadClerkJSScript (deprecated: loadClerkJsScript) - clerkJSScriptUrl (deprecated: clerkJsScriptUrl) - buildClerkJSScriptAttributes (deprecated: buildClerkJsScriptAttributes) - setClerkJSLoadingErrorPackageName (deprecated: setClerkJsLoadingErrorPackageName) - LoadClerkJSScriptOptions (deprecated: LoadClerkJsScriptOptions) Deprecated aliases will be removed in a future major version.
- Fix clerkUIVersion: pass ui.version and ui.url to loadClerkUIScript - Rename clerkUiCtor to clerkUICtor for casing consistency - Change env var from PREFETCH_UI_DISABLED=true to PREFETCH_UI=false (removes double negation for clearer semantics)
|
@nikosdouvlis Addressed your feedback. Thanks for going through it! |
Summary
Fixes: USER-4231
This PR removes the
clerkJSVariant: 'headless'option and replaces it with a newprefetchUIprop that controls whether the@clerk/uiscript is prefetched.Changes
clerkJSVariant: 'headless'option from all SDK packagesprefetchUIprop (boolean | undefined) to control UI bundle prefetchingprefetchUI={false}- Disable prefetching the UI bundle (UI will still load on-demand when needed)prefetchUIomitted orundefined- Prefetch UI normally (default behavior)shouldPrefetchClerkUIhelper functionclerkJSVariant="headless"toprefetchUI={false}clerkUiCtor→clerkUICtorfor casing consistencyClerkJscasing in favor ofClerkJSfor consistencyloadClerkJsScript→loadClerkJSScriptclerkJsScriptUrl→clerkJSScriptUrlbuildClerkJsScriptAttributes→buildClerkJSScriptAttributessetClerkJsLoadingErrorPackageName→setClerkJSLoadingErrorPackageNameLoadClerkJsScriptOptions→LoadClerkJSScriptOptionsEnvironment Variables
You can disable UI prefetching via environment variable:
NEXT_PUBLIC_CLERK_PREFETCH_UI=falsePUBLIC_CLERK_PREFETCH_UI=falseCLERK_PREFETCH_UI=falseUsage
Packages Updated
@clerk/clerk-js(major)@clerk/shared(major)@clerk/react@clerk/nextjs@clerk/astro@clerk/nuxt@clerk/vue@clerk/react-router@clerk/tanstack-react-start@clerk/expo@clerk/chrome-extension@clerk/express@clerk/upgrade(codemod added)Checklist
pnpm buildpassesSummary by CodeRabbit
Breaking Changes
New Features
Tests / Docs
✏️ Tip: You can customize this high-level summary in your review settings.