role-switch-redirectrun.md01_define/output/spec.mdClerk is configured for multi-session auth, so a user can hold several accounts/roles at once and
switch between them from the Clerk UserButton. Today, switching sessions sends the user to the
marketing site, which only offers a generic "Dashboard" button — an extra, confusing hop instead of
landing them where they were heading. The cause is that neither ClerkProvider
(apps/web/components/providers.tsx, apps/marketing/components/auth-provider.tsx) nor any
UserButton sets Clerk's post-switch redirect URLs (afterSwitchSessionUrl,
afterMultiSessionSingleSignOutUrl), so Clerk falls back to a default origin instead of the
platform. This friction hits a core navigation flow for every persona, undermining the "Refine the
Bridge" initiative's focus on dashboard usability and the small interaction details that keep users
engaged (a contributor to the Q2 vendor active-engagement objective).
The platform already has everything needed to route correctly: ROLE_HOME in
apps/web/lib/auth.ts maps each role to its dashboard, and the platform root (apps/web/app/page.tsx
plus apps/web/proxy.ts) already detects the active session's role and forwards to that dashboard.
The fix is to point Clerk's post-switch redirects at that role-aware root.
Configure Clerk's session-switch redirects so that switching account/role (or signing out of one of several active sessions) always lands the user on their correct dashboard, on both surfaces where a switch can occur:
apps/web) — set the post-switch and multi-session single-sign-out redirects to
the platform root /. The existing root route re-reads the now-active session's role and forwards
to ROLE_HOME[role] (e.g. an expert lands on /expert, a vendor on /vendor), so the landing is
role-aware for every persona and uses the single existing source of truth.apps/marketing) — set the same post-switch / single-sign-out redirects so a
switch from the marketing UserButton sends the user into the platform root (the platform then
routes to the right dashboard) rather than leaving them on the marketing page. The "Dashboard"
button continues to point into the platform root so it, too, resolves to the role dashboard.No new routing logic is introduced — the change wires Clerk's redirect URLs to the role-aware platform root that already exists.
UserButton on the
web platform lands directly on the newly-active role's dashboard (per ROLE_HOME), with no
intermediate stop on the marketing site.UserButton on the marketing site sends the user into the
platform and resolves to the newly-active role's dashboard, not back to a marketing page.ROLE_HOME mapping rather than any hardcoded per-role path.apps/web/proxy.ts (the redirect lands on / and the middleware
routes onward as it does today).OrganizationSwitcher) — this
run only fixes where Clerk's existing switch flow redirects to.afterSignInUrl / afterSignOutUrl for the normal (non-switch) sign-in and sign-out
flows, or the sign-in/sign-up pages' forceRedirectUrl handling.ROLE_HOME mappings, or middleware authorization rules.apps/dashboards mock app (standalone, mock-only — not part of the live auth flow).02_build/output/notes.mdfix: role-switch-redirect — land on dashboard after session switchThe root cause was that Clerk's multi-session redirect URLs were never set, so switching
account/role (or signing out of one of several sessions) fell back to a default that dropped the user
on the marketing site. The fix wires those redirects to the role-aware platform root /, which the
web app already resolves to the correct dashboard via ROLE_HOME (apps/web/lib/auth.ts,
apps/web/app/page.tsx, apps/web/proxy.ts). No new routing logic was added.
apps/web/components/providers.tsx: set afterMultiSessionSingleSignOutUrl="/" on the web
ClerkProvider — signing out of one session lands on the remaining session's role dashboard.apps/web/components/sidebar/app-sidebar.tsx: set afterSwitchSessionUrl="/" on the sidebar
UserButton — switching account/role lands on the newly-active role's dashboard.apps/marketing/components/auth-provider.tsx: set
afterMultiSessionSingleSignOutUrl="https://platform.sustentus.com/" on the marketing
ClerkProvider — single sign-out routes into the platform, which resolves the dashboard.apps/marketing/components/navigation.tsx: added a PLATFORM_URL constant; set
afterSwitchSessionUrl={${PLATFORM_URL}/} on both (desktop + mobile) UserButtons; pointed the
mobile "Dashboard" link at the platform root (it previously targeted /auth, which is not a real
web route — (auth) is a route group, not a path segment).UserButton switch lands on the newly-active role's dashboard — afterSwitchSessionUrl="/" → / resolves via ROLE_HOME, no marketing hop.UserButton switch routes into the platform and resolves to the role dashboard — afterSwitchSessionUrl points at the platform root.afterMultiSessionSingleSignOutUrl set on both ClerkProviders.ROLE_HOME — redirect target is / (role-aware), never a hardcoded per-role path./, so apps/web/proxy.ts runs its existing onboarding routing unchanged.ROLE_HOME mapping.https://platform.sustentus.com origin already used by
the nav's Dashboard links (no platform-URL env var exists in the repo).03_release/output/changelog.mdIf you hold more than one account or role, switching between them now takes you straight to the right dashboard:
Live entry: apps/help/app/changelog/2026-06-22-role-switch-redirect/page.mdx
03_release/output/investor-update.mdWho it's for: all six roles — admin, CSM, SDM, expert, vendor, customer What shipped: switching account or role now takes you straight to that role's dashboard, instead of detouring through the marketing site. Why it matters: Refine the Bridge — removing the small friction in everyday navigation that keeps multi-role users engaged.
Multi-session sign-out and all six role dashboards now route correctly.
Dig deeper: <merged-PR URL> · <changelog entry URL>