Skip to content

feat(ui): show the account switcher when signed-in sessions exist - #9583

Draft
djgould wants to merge 1 commit into
mainfrom
dg/signin-account-switcher-redirect
Draft

feat(ui): show the account switcher when signed-in sessions exist#9583
djgould wants to merge 1 commit into
mainfrom
dg/signin-account-switcher-redirect

Conversation

@djgould

@djgould djgould commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Description

On multi-session instances, visiting the sign-in start screen while the client already has signed-in sessions now redirects to the existing account switcher (the choose route) instead of rendering the identifier form.

Motivation: flows that route through sign-in — most visibly OAuth authorization (clerk auth login, MCP clients, any "Sign in with X" against a Clerk instance) — currently force already-signed-in users to retype their email on the identifier form, only to be password-skipped into the session they already had. FAPI redirects those flows to /sign-in?redirect_url=<consent screen>, so the fix lives entirely in <SignIn>: pick your account (or continue as the only one), then land on the consent screen. redirect_url is already in PRESERVED_QUERYSTRING_PARAMS, so the internal navigation keeps the destination.

Behavior:

  • Single-session instances: unchanged (withRedirectToAfterSignIn already forwards signed-in visitors before the new guard runs).
  • Multi-session, 0 signed-in sessions: unchanged (identifier form).
  • Multi-session, ≥1 signed-in session: account switcher.
  • ?__clerk_add_account bypasses the switcher and renders the form. The switcher's own Add account action now sets it (previously it would loop) and also preserves redirect_url, fixing a pre-existing gap where an account added mid-flow lost its destination.

Testing: vitest suites for SignInStart (new: redirect, bypass, no-session cases), SignInAccountSwitcher (un-skipped the add-account test via a windowNavigate mock), and UserButton all pass. Manual: dashboard prototype of the same rule is running in clerk/dashboard#10106.

Note for reviewers: this changes the default for multi-session apps on upgrade — a signed-in visit to /sign-in shows the switcher where the form used to be. If we want an escape hatch beyond the query param, a <SignIn> prop is a cheap follow-up.

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.

Type of change

  • 🌟 New feature

🤖 Generated with Claude Code

On multi-session instances, the sign-in start screen redirects to the
existing choose route instead of rendering the identifier form when the
client already has signed-in sessions. Flows that route through sign-in
(e.g. OAuth authorization) continue with an existing account instead of
asking for the email again. Add-account navigations bypass the switcher
via __clerk_add_account, which the switcher's own action now sets while
preserving redirect_url.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 26, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview Aug 26, 2026 6:37pm
swingset Ready Ready Preview Aug 26, 2026 6:37pm

Request Review

@changeset-bot

changeset-bot Bot commented Aug 26, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 39e732a

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

This PR includes changesets to release 23 packages
Name Type
@clerk/ui Minor
@clerk/shared Patch
@clerk/astro Patch
@clerk/chrome-extension Patch
@clerk/react Patch
@clerk/swingset Patch
@clerk/vue Patch
@clerk/backend Patch
@clerk/clerk-js Patch
@clerk/electron Patch
@clerk/expo-passkeys Patch
@clerk/expo Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/headless Patch
@clerk/hono Patch
@clerk/localizations Patch
@clerk/msw Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/tanstack-react-start Patch
@clerk/testing 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

@pkg-pr-new

pkg-pr-new Bot commented Aug 26, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@9583

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@9583

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@9583

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@9583

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@9583

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@9583

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@9583

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@9583

@clerk/expo-google-signin

npm i https://pkg.pr.new/@clerk/expo-google-signin@9583

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@9583

@clerk/express

npm i https://pkg.pr.new/@clerk/express@9583

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@9583

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@9583

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@9583

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@9583

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@9583

@clerk/react

npm i https://pkg.pr.new/@clerk/react@9583

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@9583

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@9583

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@9583

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@9583

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@9583

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@9583

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@9583

commit: 39e732a

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.

1 participant