clerk-js ignores new `ClerkProvider` options after the first load, so `afterSignOutUrl` keeps its first value
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 57/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- Active
- Stack technique
- next.js, react, typescript
- Domaine
- authentication
Piste de recherche
Start with packages/clerk-js/src/core/clerk.ts and the __internal_updateProps and URL-builder methods; then read the options-update effect in packages/react/src/contexts/ClerkProvider.tsx. Run the linked reproduction using its listed setup steps and compare the sign-out destination before and after navigating from /en to /sk. Done means the updated provider options are respected in both the changing-provider and mounted-provider cases.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Preliminary Checks
-
I have reviewed the documentation: https://clerk.com/docs
-
I have searched for existing issues: https://github.com/clerk/javascript/issues
-
I have not already reached out to Clerk support via email or Discord (if you have, no need to open an issue here)
-
This issue is not a question, general help request, or anything other than a bug report directly related to Clerk. Please ask questions in our Discord community: https://clerk.com/discord.
Reproduction
https://github.com/Joozty/clerk-nextjs-activity-repro
Publishable key
Not shared. The reproduction works with any development instance: put your own key in .env.local (see .env.example).
Description
clerk-js keeps the options from its first load(). If a prop of <ClerkProvider> changes later, clerk-js ignores the new value. For example, an app with two languages passes afterSignOutUrl="/en" or afterSignOutUrl="/sk". A user opens /en, clicks a link to /sk, and signs out. Clerk sends the user to /en, not to /sk.
This happens with or without cacheComponents. #5935 had the same cause for signInUrl. Its author closed it without a fix, and it is now locked.
Steps to reproduce:
- Clone the reproduction and run
pnpm install. - Copy
.env.exampleto.env.local. Set the publishable key of your own development instance there. - Run
pnpm devand open http://localhost:3000/en. - Click the
/sklink. The layout now renders<ClerkProvider afterSignOutUrl="/sk">. - Click Read Clerk.buildAfterSignOutUrl().
Expected behavior:
http://localhost:3000/sk.
Actual behavior:
http://localhost:3000/en. <UserButton> signs out to the URL from clerk.buildAfterSignOutUrl() (see packages/ui/src/contexts/components/UserButton.ts). I tested this with a real account: after I click /sk and sign out, I land on /en.
Why it happens:
- When you click
/sk, the newClerkProvidersends its options to clerk-js. Its effect calls__internal_updateProps({ options }), and the options includeafterSignOutUrl: "/sk". I checked this in the browser. Clerk.__internal_updateProps()inpackages/clerk-js/src/core/clerk.tsmerges the new options withthis.#options. But it gives the result only to Clerk's UI. It never saves it inthis.#options. Onlyload()setsthis.#options.buildAfterSignOutUrl(),buildSignInUrl(),buildSignUpUrl(),buildAfterSignInUrl()andbuildAfterSignUpUrl()readthis.#options. So they keep the first values.- There is a second, smaller problem in
@clerk/react. The effect inpackages/react/src/contexts/ClerkProvider.tsxthat calls__internal_updateProps({ options })depends only on[mergedOptions.localization]. So if oneClerkProviderstays mounted and onlyafterSignOutUrlchanges, the new value is not even sent.
#4498 added the merge in __internal_updateProps. Its changeset says "Re-init window.Clerk options when ClerkProvider props change", but the code only gives the merged options to the UI.
Possible fix:
- In
__internal_updateProps, save the merged options inthis.#options. This alone should fix the reproduction. - In
@clerk/react, send the options again when any option changes, not onlylocalization. This is for apps where oneClerkProviderstays mounted.
Workaround: custom code can call signOut({ redirectUrl }). But <UserButton> has no prop for the sign-out URL. By default, clerk-js loads from the Frontend API, not from node_modules, so a pnpm patch in the app can't fix it.
Related:
- #372 added the
@clerk/reacteffect that sends options only whenlocalizationchanges. - #3455 also merged the options of a new
ClerkProvideronly into the UI state. - #7243 removed
<UserButton afterSignOutUrl>in Core 3, so<UserButton>has no prop for the sign-out URL.
Environment
System:
OS: macOS 27.2
CPU: (10) arm64 Apple M4
Memory: 73.23 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.15.0 - /Users/jozef/.volta/tools/image/node/24.15.0/bin/node
npm: 11.12.1 - /Users/jozef/.volta/tools/image/node/24.15.0/bin/npm
pnpm: 12.4.1 - /Users/jozef/.volta/bin/pnpm
Browsers:
Chrome: 156.0.8078.48
Firefox: 159.0
Safari: 27.2
npmPackages:
@clerk/nextjs: 7.9.22 => 7.9.22
next: 16.4.3 => 16.4.3
react: 19.3.0 => 19.3.0
react-dom: 19.3.0 => 19.3.0
Loaded from the Frontend API:
@clerk/clerk-js: 6.41.0 (6.42.0 and main have the same code)
@clerk/ui: 1.42.0
- Langage dominant
- TypeScript
- Étoiles
- 1.8k
- Forks
- 492
- Merge moyen
- 1 j 8 h
- PR mergées (30 j)
- 374
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de clerk/javascript
-
<SignIn />: the reset password code step renders an empty, focusable back button with no accessible namePeut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
clerk/javascript#10708 ·
Les mainteneurs répondent en général sous 1 jour
-
Built-in reverification dialog lacks an accessible name (aria-dialog-name)Peut-être pris @ItsShivam05 l’a pris il y a 5 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
clerk/javascript#10548 ·
Les mainteneurs répondent en général sous 1 jour
-
MFA enrollment QR SVG lacks an accessible name (svg-img-alt)Peut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
clerk/javascript#10547 ·
Les mainteneurs répondent en général sous 1 jour
-
<SignIn />: first "Use email" click switches back to phone when `initialValues.phoneNumber` is setPeut-être pris @twicestruck l’a pris il y a 23 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
clerk/javascript#10487 ·
Les mainteneurs répondent en général sous 1 jour
-
useLoadedIsomorphicClerk misses "ready" when a ClerkProvider remounts after clerk-js has loaded — <ClerkLoading> never resolvesPeut-être à nouveau libre Une pull request pour cette issue a été fermée sans être fusionnée. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
clerk/javascript#10462 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de clerk/javascript
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
milind-soni/OpenMausBot#6730 ·
Les mainteneurs répondent en général sous 1 jour
-
`@angular/[email protected]` depends on vulnerable Vite 7.3.7 - GHSA-p4f5-76q4-ffq7 (Critical RCE)Ouvertearea: @angular/build
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
angular/angular-cli#34764 ·
Les mainteneurs répondent en général sous 1 jour
-
status/need-triage
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
google-gemini/gemini-cli#30384 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
P2
Difficulté 1/5 Moins d'une heure Accessibilité débutants 84/100
Les mainteneurs répondent en général sous 1 jour
-
area:image documentation good first issue
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 1 jour