Skip to content

feat(mosaic): wire up sign-up with step routing - #10881

Open
austincalvelage wants to merge 73 commits into
austin/mosaic-auth-alternative-channel-submitfrom
austin/mosaic-sign-up-routing
Open

austincalvelage wants to merge 73 commits into
austin/mosaic-auth-alternative-channel-submitfrom
austin/mosaic-sign-up-routing

Conversation

@austincalvelage

@austincalvelage austincalvelage commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Description

Wires up the Mosaic <SignUp /> component, building on Alex's flow guide (packages/mosaic/docs/internals/sign-in-sign-up-flow.md). Each sign-up screen is its own component, and it mounts when its route is active. Routing is virtual for now, and should be easy to move to path routing once #10860 lands. SignUp takes someone from the first form to a signed-in session: details, email or phone code, then on to the app. It is not exported from the package entry yet.

Stacked on #10957. The PRs it built on, #10867, #10868 and #10883, have merged. Below it are channel on SignUpFuture.create() (#10955), which the WhatsApp PR above uses, then the AuthStartOver block (#10956) and the alternative-channel fix (#10957). #10955 is a @clerk/shared type change, since clerk-js already sends channel.

features/sign-up/
├── sign-up.routes.ts       route table + which route each step allows
├── sign-up.model.ts        Clerk adapter, grouped by screen
├── sign-up.controller.ts   route guard + next step + finish
├── sign-up.view.tsx        route → screen
├── sign-up.tsx             component + slots
├── sign-up-details/        start + continue
├── sign-up-verify/         code screen
└── sign-up-restricted/     restricted + waitlist

Clerk guards the route if the sign-up isn't ready for that screen

<Card.Root align='center'>
  <Flow.Root value={screen} state={props}>
    {({ start, verifyEmail }) => (
      <>
        {/* / */}
        <Flow.Step ids={['start']}>
          <SignUpDetailsStep {...start} />
        </Flow.Step>

        {/* /verify-email-address, /continue/verify-email-address */}
        <Flow.Step ids={['verifyEmail', 'continueVerifyEmail']}>
          {verifyEmail}
        </Flow.Step>
      </>
    )}
  </Flow.Root>
</Card.Root>

1. The route you're on is the screen you get, unless the model's step says otherwise.

// sign-up.routes.ts
export function shownRoute(route, step) {
  if (step.type === 'unknown') return undefined; // can't handle this step -> Start over
  return allowedRoute(route, step) ? route : routeFor(step, route); // keep the route, or use the step's
}

// sign-up.controller.ts
const shown = shownRoute(route, flow.step);
useRouteGuard({ route, go }, shown); // replaces a route the step doesn't allow, with no history entry

2. The code screen sends its code when it mounts if one hasn't been sent yet, and starts the resend countdown either way. Edit stays disabled until that first code is out.

// the model's verification group
needsCode: step.type === 'verify_email' && !step.sent,

// inside the verify screen's own controller
useEffect(() => {
  send({ type: needsCode ? 'SEND' : 'ALREADY_SENT' }); // ALREADY_SENT starts the countdown, like ui's code card
}, [needsCode, send]);

The verify screen runs its own controller, so the wrapper builds it and passes it to the view as a slot:

verifyEmail={<SignUpVerify key={attempt} channel='email' {...verifyEmail} />}

3. The form lives above the screens, so start and continue share it, and your password is still there when you come back from the code screen.

// sign-up.controller.ts
const details = useSignUpDetailsController(model.details, { purpose, onNext: next, ... });

return {
  start: details.start,
  continue: details.continue,
};

4. Clerk wipes the sign-up once the code is accepted, which would flash the first form before the app navigates. So while finishing, we keep rendering the model we left from, like the switcher's frozenModel.

const [finishSnapshot, sendFinish] = useMachine(finishMachine);
const model = finishSnapshot.context.frozenModel ?? liveModel;

The machine holds that model while the live step is leaving, or a task whose data hasn't loaded. The wrapper runs the organization task's model once, passes it to the task screen and tells the controller when it has loaded, so the task replaces the code screen in the same card with no skeleton in between. If the app set its own URL for that task in taskUrls, sign-up goes there. Once the hold ends with the session signed in, a <SignUp /> that stays mounted renders nothing.

5. The continue screen asks for what FAPI says is still missing, instead of rebuilding that list from the instance settings.

// sign-up.model.ts
continueFieldsFor: identifier => continueFields(signUp, identifier), // from signUp.missingFields
continueCanSwitchIdentifier: missesEitherIdentifier(signUp), // missing and optional email/phone -> pick one

A missing email, phone or username that's also in optional_fields means any one will do, so the form shows one field with the email/phone switch. A password typed there goes out with the update.

6. If FAPI needs something the continue screen can't ask for, like a required OAuth provider, you get Start over instead of a form you can't finish.

// sign-up.model.ts
return step.type === 'fields' && !continueCanSatisfy(resource) ? { type: 'unknown' } : step;

7. Continue stays disabled until every required field is filled. Form skips the browser's validation popup, so the form checks it itself, like the other Mosaic forms.

// sign-up-details.controller.ts
canSubmit: values => hasRequired(values, fields, consentRequired),

8. A signed-in visitor doesn't see the form in single-session mode. The model reports a signed_in step. The controller keeps the step it saw at mount, so only a visit that arrives signed in leaves, and finishing a sign-up doesn't count as one.

// sign-up.model.ts
leave: environment.authConfig.singleSessionMode
  ? () => {
      const task = session?.currentTask;
      void router.navigate(task ? taskUrl(task) : afterSignUpUrl);
    }
  : undefined,

9. redirect_url in the query decides where sign-up lands, and the sign-in and waitlist links keep it.

const returnUrl = query.get('redirect_url') ?? undefined;
const afterSignUpUrl = clerk.buildAfterSignUpUrl({ params: query });

The model is grouped by screen

The model reads Clerk in one place and returns flow, app, navigation, details and verification.email / verification.phone. Each screen folder takes its group whole, so one screen is one folder to read. features.md now describes this as the shape for a flow with several screens.

Changes outside sign-up

  • SignUpFutureUpdateParams gains password?, matching the create params. clerk-js already sends every update param, so this is a @clerk/shared type change with a patch changeset.
  • The organization task exports isTaskChooseOrganizationReady(model), and TaskChooseOrganizationContent takes the model, so sign-up runs the task model once.

Known gaps

  • Redirect props on SignUpProps are not supported yet, because they add public API. Only redirect_url from the query is read.
  • The sign-in and waitlist links carry redirect_url only, not the rest of the query.
  • Transfers to and from sign-in are planned, not built. Sign-up keeps the current screen on a transfer step.

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:

@vercel

vercel Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
clerk-js-sandbox Ready Ready Preview Nov 24, 2026 1:29am UTC
mosaic-docs Ready Ready Preview Nov 24, 2026 1:29am UTC
swingset Ready Ready Preview Nov 24, 2026 1:29am UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The PR adds a routed sign-up flow with screen-specific contracts, model and controller logic, verification screens, and route handling. It adds a fake sign-up API and feature tests. Organization selection can render in an embedded mode. Mosaic documentation and SwingSet stories are updated for the screen-based flow, and SwingSet adds a live sign-up page.

Estimated code review effort: 4 (Complex) | ~60 minutes

Suggested reviewers: alexcarpenter, kylemac, ephem

Merge Risk: Moderate · previous review d4ef0

The new Mosaic sign-up flow has several open functional gaps. Continuing a sign-up can drop the password, and completed or transferable sign-ups can stall. Some reset and error states give no feedback. The component is not yet exported publicly, so exposure is limited, but these should be resolved or accepted before merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "feat(mosaic): wire up sign-up with step routing" matches the main change: the PR wires up the Mosaic SignUp component with virtual step/route handling. The changeset includes new sign-up ro…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description describes the Mosaic component wiring, the per-screen component layout, routing and route guard behavior, the verification code-send on mount, the shared details form, finis…
Full details: Title check

Explanation

The title "feat(mosaic): wire up sign-up with step routing" matches the main change: the PR wires up the Mosaic SignUp component with virtual step/route handling. The changeset includes new sign-up routes, controller, model, views, and tests that match this description. The title is specific and concise.

Full details: Description check

Explanation

The description describes the Mosaic <SignUp /> component wiring, the per-screen component layout, routing and route guard behavior, the verification code-send on mount, the shared details form, finish snapshot handling, and changes outside sign-up (shared types, organization task export). It is directly related to the changeset, so it is not off-topic or vague.

Finishing Touches

Fix failing CI checks

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Linked repositories: This review skipped 6 repositories. Cross-repository analysis may be incomplete. Check linked repository access and settings.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 73f7e56 and d4ef0b3.

Files selected for processing: 3

  • packages/mosaic/src/__tests__/feature/fake-fapi.ts
  • packages/mosaic/src/features/sign-up/__tests__/sign-up.feature.test.tsx
  • packages/mosaic/src/features/sign-up/sign-up.model.ts
Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

Included review availability: This review used your included allowance. 8 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 10 reviews per hour.

@changeset-bot

changeset-bot Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 319a9c3

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

This PR includes changesets to release 24 packages
Name Type
@clerk/shared Patch
@clerk/astro Patch
@clerk/backend Patch
@clerk/chrome-extension Patch
@clerk/clerk-js Patch
@clerk/electron Patch
@clerk/expo-passkeys Patch
@clerk/expo Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/hono Patch
@clerk/localizations Patch
@clerk/mosaic Patch
@clerk/msw Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/react Patch
@clerk/swingset Patch
@clerk/tanstack-react-start Patch
@clerk/testing Patch
@clerk/ui Patch
@clerk/vue Patch
@clerk/mosaic-docs 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
vercel Bot temporarily deployed to Preview – clerk-js-sandbox November 18, 2026 00:13 Inactive
@austincalvelage
austincalvelage changed the base branch from austin/shared-sign-up-form-fields to austin/shared-sign-up-next-step-order November 18, 2026 00:24
@pkg-pr-new

pkg-pr-new Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/electron

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

@clerk/electron-passkeys

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

@clerk/eslint-plugin

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

@clerk/expo

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

@clerk/expo-biometrics

npm i https://pkg.pr.new/@clerk/expo-biometrics@10881

@clerk/expo-google-signin

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

@clerk/expo-native-components

npm i https://pkg.pr.new/@clerk/expo-native-components@10881

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/hono

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

@clerk/localizations

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

@clerk/mosaic

npm i https://pkg.pr.new/@clerk/mosaic@10881

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

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

@clerk/upgrade

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

@clerk/vue

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

commit: 319a9c3

…orts missing

The continue screen now asks for the fields FAPI lists in missing_fields instead of re-deriving them from the instance settings. A missing email, phone or username that FAPI lists as optional is one choice, so the form asks for one of them. The fake FAPI lists every optional identifier as missing when none was given, as FAPI does.
…e continue screen cannot ask for

When FAPI lists a missing requirement the continue form has no field for, such as a required OAuth provider, the step is unknown, so the user sees Start over instead of a form that can't finish. The fake FAPI lists required social providers as missing, as FAPI does.
… continue test

The switch round trip is covered by the progressive test. Here it typed the email twice on CI, so the test only checks that one field and the switch show.
…d is filled

The form skips the browser's validation popup, so nothing stopped a sign-up from submitting with a required field empty. Continue now stays disabled until each required field and, when shown, legal consent are filled, as the other Mosaic forms do with canSubmit.
…n a code screen

Clerk's sign-up signals are shared across Clerk instances. A test that ended while its code screen was still sending wrote that sign-up back into the signals after the next test reset them, so the next form prefilled the old email or username and typing doubled it on CI.
…opens with a code already out

The countdown only started when the code screen sent the code itself, so a reload, a reopened verify route or a code sent by the form left Resend available at once. It now starts on arrival either way, as the legacy code card does.
SignUpFuture.update() now accepts a password, so a sign-up created
without one can finish from the continue screen instead of asking again.
The after sign-up URL reads redirect_url and the redirect query params,
and the sign-in and waitlist links carry redirect_url on.
The sign-up wrapper reads the choose-organization task model and passes
it to the task screen, instead of the sign-up model calling the task's
wrapper hook and the screen running the model again. The controller
holds the finished screen until the task has loaded.
… finishing

In single-session mode a signed-in visit leaves for the after sign-up
URL, or the session's task URL, without showing the form, as the legacy
withRedirectToAfterSignUp does. In multi-session mode the form stays, so
the user can add an account. Once a sign-up this component ran has
created its session, it renders nothing instead of holding the last
screen busy while it stays mounted.
…tion

The model reads the email verification's supportedStrategies instead of
the instance settings, and the models guide names supportedStrategies as
the answer to read before anything is sent.
Mark entry actions and transfer as planned, and describe the signed_in
step, the end state after finishing, redirect_url, and how the wrapper
passes the organization task.
The start-over notice reads its copy from `message` and `pending` since the
AuthStartOver block moved to blocks/auth, so sign-up passes both and shows a
failed Start over in the alert with the button kept available.
SignUpVerifyScreen requires isPending, so the example did not compile when
copied.
…in story

The sign-up step edits emailAddress, but submitSignUp still checked and sent
identifier, so a changed email never reached validation or the code screen.
Remounting alone resumed the sign-up in progress, so Reset returned to the
code screen instead of the start.
… test

- Remove the start-over failure test. It stubbed clerk.client.resetSignUp, and
  signUp.reset() makes no request, so FAPI cannot produce that failure.
- Fold "links to sign-in from the form" into the redirect_url sign-in link test.
- Rename the reopened verify route test to what it asserts: no second code.
The fake FAPI asks a new sign-up for enterprise SSO when its email domain
belongs to an enterprise connection, as clerk_go does. Sign-up has no
enterprise screen yet, so the feature test covers the Start over it shows.

This branch was successfully deployed

2 active deployments
Preview – swingset — 319a9c3f Deployed Nov 24, 2026 by vercel[bot]
Preview – clerk-js-sandbox — 319a9c3f Deployed Nov 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants