clerk-js ignores new `ClerkProvider` options after the first load, so `afterSignOutUrl` keeps its first value
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 57/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- next.js, react, typescript
- Bereich
- authentication
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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
- Vorherrschende Sprache
- TypeScript
- Sterne
- 1.8k
- Forks
- 492
- Ø Merge
- 1 T. 8 Std.
- Gemergte PRs (30 T.)
- 374
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus clerk/javascript
-
<SignIn />: the reset password code step renders an empty, focusable back button with no accessible nameEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
clerk/javascript#10708 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Built-in reverification dialog lacks an accessible name (aria-dialog-name)Evtl. vergeben @ItsShivam05 hat das vor 5 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
clerk/javascript#10548 ·
Maintainer antworten meist innerhalb von 1 Tag
-
MFA enrollment QR SVG lacks an accessible name (svg-img-alt)Evtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
clerk/javascript#10547 ·
Maintainer antworten meist innerhalb von 1 Tag
-
<SignIn />: first "Use email" click switches back to phone when `initialValues.phoneNumber` is setEvtl. vergeben @twicestruck hat das vor 23 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
clerk/javascript#10487 ·
Maintainer antworten meist innerhalb von 1 Tag
-
useLoadedIsomorphicClerk misses "ready" when a ClerkProvider remounts after clerk-js has loaded — <ClerkLoading> never resolvesEvtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
clerk/javascript#10462 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in clerk/javascript
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
milind-soni/OpenMausBot#6730 ·
Maintainer antworten meist innerhalb von 1 Tag
-
`@angular/[email protected]` depends on vulnerable Vite 7.3.7 - GHSA-p4f5-76q4-ffq7 (Critical RCE)Offenarea: @angular/build
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
angular/angular-cli#34764 ·
Maintainer antworten meist innerhalb von 1 Tag
-
status/need-triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
google-gemini/gemini-cli#30384 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
P2
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 84/100
Maintainer antworten meist innerhalb von 1 Tag
-
area:image documentation good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 1 Tag