Skip to content

fix(react): Respect ui prop when Clerk instance is passed to IsomorphicClerk#7997

Draft
royanger wants to merge 5 commits intomainfrom
roy/fix-clerk-loaded-without-ui-error-in-chrome-extensions
Draft

fix(react): Respect ui prop when Clerk instance is passed to IsomorphicClerk#7997
royanger wants to merge 5 commits intomainfrom
roy/fix-clerk-loaded-without-ui-error-in-chrome-extensions

Conversation

@royanger
Copy link
Member

@royanger royanger commented Mar 5, 2026

Description

The guard that causes the bug is:

const shouldLoadUi = !this.options.Clerk && this.options.standardBrowser !== false;

@clerk/react, @clerk/nextjs, etc.: this.options.Clerk is undefined → !this.options.Clerk is true → shouldLoadUi is true → getClerkUIEntryChunk() runs → finds uiProp.ClerkUI from the ui prop and returns it → ClerkUI is valid, no overwrite.

@clerk/chrome-extension: this.options.Clerk is a Clerk instance (truthy) → !this.options.Clerk is false → shouldLoadUi is false → ClerkUI = undefined → overwrites the valid ClerkUI from the ui prop.

The chrome-extension needs its own Clerk instance because it has to wire up extension-specific hooks (JWT handling, cookie syncing, storage cache, etc.) in createClerkClient before the instance is used.

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:

@changeset-bot
Copy link

changeset-bot bot commented Mar 5, 2026

🦋 Changeset detected

Latest commit: 55641a5

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

This PR includes changesets to release 6 packages
Name Type
@clerk/react Minor
@clerk/chrome-extension Patch
@clerk/expo Patch
@clerk/nextjs Patch
@clerk/react-router Patch
@clerk/tanstack-react-start 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 Mar 5, 2026

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

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Mar 6, 2026 10:41pm

Request Review

@github-actions github-actions bot added the react label Mar 5, 2026
@royanger royanger changed the title fix: Respect ui prop when Clerk instance is passed to ClerkProvider fix(react): Respect ui prop when Clerk instance is passed to IsomorphicClerk Mar 5, 2026
@royanger
Copy link
Member Author

royanger commented Mar 5, 2026

!snapshot

3 similar comments
@royanger
Copy link
Member Author

royanger commented Mar 5, 2026

!snapshot

@tmilewski
Copy link
Member

!snapshot

@royanger
Copy link
Member Author

royanger commented Mar 5, 2026

!snapshot

@@ -474,7 +474,7 @@ export class IsomorphicClerk implements IsomorphicLoadedClerk {
this.beforeLoad(clerk);
// Only load UI scripts in standard browser environments (not native/headless)
const shouldLoadUi = !this.options.Clerk && this.options.standardBrowser !== false;
Copy link
Member

Choose a reason for hiding this comment

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

Do you think shouldLoadUi should be false if this.options.ui?.ClerkUI exists? or is that already handled elsewhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope. I was mostly starting with a draft PR so I could get snapshots, since this issue wasn't showing up in local testing. The updated change in 2dc46ff should be a better approach, but I still need to test it.

@royanger
Copy link
Member Author

royanger commented Mar 6, 2026

!snapshot

@royanger
Copy link
Member Author

royanger commented Mar 6, 2026

!snapshot

@clerk-cookie
Copy link
Collaborator

Hey @royanger - the snapshot version command generated the following package versions:

Package Version
@clerk/agent-toolkit 0.3.2-snapshot.v20260306205749
@clerk/astro 3.0.2-snapshot.v20260306205749
@clerk/backend 3.0.2-snapshot.v20260306205749
@clerk/chrome-extension 3.1.0-snapshot.v20260306205749
@clerk/clerk-js 6.0.1-snapshot.v20260306205749
@clerk/dev-cli 0.1.1-snapshot.v20260306205749
@clerk/expo 3.0.2-snapshot.v20260306205749
@clerk/expo-passkeys 1.0.2-snapshot.v20260306205749
@clerk/express 2.0.2-snapshot.v20260306205749
@clerk/fastify 3.0.2-snapshot.v20260306205749
@clerk/hono 0.0.4-snapshot.v20260306205749
@clerk/localizations 4.0.1-snapshot.v20260306205749
@clerk/msw 0.0.2-snapshot.v20260306205749
@clerk/nextjs 7.0.2-snapshot.v20260306205749
@clerk/nuxt 2.0.2-snapshot.v20260306205749
@clerk/react 6.1.0-snapshot.v20260306205749
@clerk/react-router 3.0.2-snapshot.v20260306205749
@clerk/shared 4.0.1-snapshot.v20260306205749
@clerk/tanstack-react-start 1.0.2-snapshot.v20260306205749
@clerk/testing 2.0.2-snapshot.v20260306205749
@clerk/ui 1.1.0-snapshot.v20260306205749
@clerk/upgrade 2.0.2-snapshot.v20260306205749
@clerk/vue 2.0.2-snapshot.v20260306205749

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/agent-toolkit

npm i @clerk/agent-toolkit@0.3.2-snapshot.v20260306205749 --save-exact

@clerk/astro

npm i @clerk/astro@3.0.2-snapshot.v20260306205749 --save-exact

@clerk/backend

npm i @clerk/backend@3.0.2-snapshot.v20260306205749 --save-exact

@clerk/chrome-extension

npm i @clerk/chrome-extension@3.1.0-snapshot.v20260306205749 --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@6.0.1-snapshot.v20260306205749 --save-exact

@clerk/dev-cli

npm i @clerk/dev-cli@0.1.1-snapshot.v20260306205749 --save-exact

@clerk/expo

npm i @clerk/expo@3.0.2-snapshot.v20260306205749 --save-exact

@clerk/expo-passkeys

npm i @clerk/expo-passkeys@1.0.2-snapshot.v20260306205749 --save-exact

@clerk/express

npm i @clerk/express@2.0.2-snapshot.v20260306205749 --save-exact

@clerk/fastify

npm i @clerk/fastify@3.0.2-snapshot.v20260306205749 --save-exact

@clerk/hono

npm i @clerk/hono@0.0.4-snapshot.v20260306205749 --save-exact

@clerk/localizations

npm i @clerk/localizations@4.0.1-snapshot.v20260306205749 --save-exact

@clerk/msw

npm i @clerk/msw@0.0.2-snapshot.v20260306205749 --save-exact

@clerk/nextjs

npm i @clerk/nextjs@7.0.2-snapshot.v20260306205749 --save-exact

@clerk/nuxt

npm i @clerk/nuxt@2.0.2-snapshot.v20260306205749 --save-exact

@clerk/react

npm i @clerk/react@6.1.0-snapshot.v20260306205749 --save-exact

@clerk/react-router

npm i @clerk/react-router@3.0.2-snapshot.v20260306205749 --save-exact

@clerk/shared

npm i @clerk/shared@4.0.1-snapshot.v20260306205749 --save-exact

@clerk/tanstack-react-start

npm i @clerk/tanstack-react-start@1.0.2-snapshot.v20260306205749 --save-exact

@clerk/testing

npm i @clerk/testing@2.0.2-snapshot.v20260306205749 --save-exact

@clerk/ui

npm i @clerk/ui@1.1.0-snapshot.v20260306205749 --save-exact

@clerk/upgrade

npm i @clerk/upgrade@2.0.2-snapshot.v20260306205749 --save-exact

@clerk/vue

npm i @clerk/vue@2.0.2-snapshot.v20260306205749 --save-exact

@royanger
Copy link
Member Author

royanger commented Mar 6, 2026

!snapshot

@clerk-cookie
Copy link
Collaborator

Hey @royanger - the snapshot version command generated the following package versions:

Package Version
@clerk/agent-toolkit 0.3.2-snapshot.v20260306224304
@clerk/astro 3.0.2-snapshot.v20260306224304
@clerk/backend 3.0.2-snapshot.v20260306224304
@clerk/chrome-extension 3.1.0-snapshot.v20260306224304
@clerk/clerk-js 6.1.0-snapshot.v20260306224304
@clerk/dev-cli 0.1.1-snapshot.v20260306224304
@clerk/expo 3.1.0-snapshot.v20260306224304
@clerk/expo-passkeys 1.0.2-snapshot.v20260306224304
@clerk/express 2.0.2-snapshot.v20260306224304
@clerk/fastify 3.0.2-snapshot.v20260306224304
@clerk/hono 0.0.4-snapshot.v20260306224304
@clerk/localizations 4.1.0-snapshot.v20260306224304
@clerk/msw 0.0.2-snapshot.v20260306224304
@clerk/nextjs 7.0.2-snapshot.v20260306224304
@clerk/nuxt 2.0.2-snapshot.v20260306224304
@clerk/react 6.1.0-snapshot.v20260306224304
@clerk/react-router 3.0.2-snapshot.v20260306224304
@clerk/shared 4.1.0-snapshot.v20260306224304
@clerk/tanstack-react-start 1.0.2-snapshot.v20260306224304
@clerk/testing 2.0.2-snapshot.v20260306224304
@clerk/ui 1.1.0-snapshot.v20260306224304
@clerk/upgrade 2.0.2-snapshot.v20260306224304
@clerk/vue 2.0.2-snapshot.v20260306224304

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/agent-toolkit

npm i @clerk/agent-toolkit@0.3.2-snapshot.v20260306224304 --save-exact

@clerk/astro

npm i @clerk/astro@3.0.2-snapshot.v20260306224304 --save-exact

@clerk/backend

npm i @clerk/backend@3.0.2-snapshot.v20260306224304 --save-exact

@clerk/chrome-extension

npm i @clerk/chrome-extension@3.1.0-snapshot.v20260306224304 --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@6.1.0-snapshot.v20260306224304 --save-exact

@clerk/dev-cli

npm i @clerk/dev-cli@0.1.1-snapshot.v20260306224304 --save-exact

@clerk/expo

npm i @clerk/expo@3.1.0-snapshot.v20260306224304 --save-exact

@clerk/expo-passkeys

npm i @clerk/expo-passkeys@1.0.2-snapshot.v20260306224304 --save-exact

@clerk/express

npm i @clerk/express@2.0.2-snapshot.v20260306224304 --save-exact

@clerk/fastify

npm i @clerk/fastify@3.0.2-snapshot.v20260306224304 --save-exact

@clerk/hono

npm i @clerk/hono@0.0.4-snapshot.v20260306224304 --save-exact

@clerk/localizations

npm i @clerk/localizations@4.1.0-snapshot.v20260306224304 --save-exact

@clerk/msw

npm i @clerk/msw@0.0.2-snapshot.v20260306224304 --save-exact

@clerk/nextjs

npm i @clerk/nextjs@7.0.2-snapshot.v20260306224304 --save-exact

@clerk/nuxt

npm i @clerk/nuxt@2.0.2-snapshot.v20260306224304 --save-exact

@clerk/react

npm i @clerk/react@6.1.0-snapshot.v20260306224304 --save-exact

@clerk/react-router

npm i @clerk/react-router@3.0.2-snapshot.v20260306224304 --save-exact

@clerk/shared

npm i @clerk/shared@4.1.0-snapshot.v20260306224304 --save-exact

@clerk/tanstack-react-start

npm i @clerk/tanstack-react-start@1.0.2-snapshot.v20260306224304 --save-exact

@clerk/testing

npm i @clerk/testing@2.0.2-snapshot.v20260306224304 --save-exact

@clerk/ui

npm i @clerk/ui@1.1.0-snapshot.v20260306224304 --save-exact

@clerk/upgrade

npm i @clerk/upgrade@2.0.2-snapshot.v20260306224304 --save-exact

@clerk/vue

npm i @clerk/vue@2.0.2-snapshot.v20260306224304 --save-exact

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