Skip to content

feat(custom-flows): signUpIfMissing sign-in-or-up#3202

Merged
alexisintech merged 4 commits intomainfrom
daniel/sign-up-if-missing-custom-flow
Mar 23, 2026
Merged

feat(custom-flows): signUpIfMissing sign-in-or-up#3202
alexisintech merged 4 commits intomainfrom
daniel/sign-up-if-missing-custom-flow

Conversation

@dmoerner
Copy link
Copy Markdown
Contributor

@dmoerner dmoerner commented Mar 11, 2026

🔎 Previews:

What does this solve? What changed?

Add documentation for signUpIfMissing sign-in-or-up custom flows. Frame these as an alternative to the standard approach, with tradeoffs including restrictions and a delay in providing feedback to end users on whether their account exists.

Three additional notes:

  • SDK releases are broken (?) at the moment so the underlying SDK changes have not yet been released, but it should be released very soon. SDK released
  • There is one piece of awkwardness when checking for the transfer, which I've commented on below. If it's worth making this easier with a helper in the SDK, we can definitely do that.
  • In fact, in general this custom flow is particularly complex. If you have any suggestions on how the SDK could make this easier, that would be welcome.

Deadline

It would be nice to be comfortable with sharing some form of this with Spark by end of week (March 13).
There's no rush on a broad release.

Other resources

Add documentation for `signUpIfMissing` sign-in-or-up flows. Frame these
as an alternative to the standard approach, with tradeoffs including
restrictions and a delay in providing feedback to end users on whether
their account exists.
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 11, 2026

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

Project Deployment Actions Updated (UTC)
clerk-docs Ready Ready Preview Mar 19, 2026 9:43pm

Request Review

// the code 'sign_up_if_missing_transfer'. Check for this error
// to determine if we need to transfer to sign-up.
if (error) {
if (error.errors[0]?.code === 'sign_up_if_missing_transfer') {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the new Core 3 SignIn, we have signIn.isTransferable. This checks the verification in the piggybacked object on the error. This is what we use for OAuth transfers. Unfortunately, it just doesn't work in this case. According to Claude (I am not a React expert), that's because we are checking a stale snapshot:

The piggybacking updates the underlying SignIn resource in-place, but the React hook snapshot is stale until the next render. Since we're checking signIn.isTransferable synchronously in the same await chain, React hasn't re-rendered yet.

Therefore, we have to manually check the error code itself. This custom flow is already complex, but if it would help to add an SDK helper here (or anywhere) I'm very happy to do so.

@dmoerner dmoerner requested a review from alexisintech March 11, 2026 01:14
@dmoerner
Copy link
Copy Markdown
Contributor Author

Hi @alexisintech, I believe you worked on the Core 3 custom flow docs, so I wanted to tag you if you'd be able to take a look at my attempt to put together a 'signUpIfMissing' custom flow guide.


## Enable email and password authentication
- [**Standard flow**](#standard-sign-in-or-up-flow): The sign-in attempt immediately tells you whether an account exists. If it doesn't, you start the sign-up flow. This is simple and gives users immediate feedback, but it reveals whether an account exists before any verification, making it susceptible to [user enumeration](/docs/guides/secure/user-enumeration-protection) attacks.
- [**`signUpIfMissing` flow**](#sign-in-or-up-with-signupifmissing): The sign-in proceeds to verification regardless of whether an account exists. Only after verification does the backend reveal whether the account exists or needs to be created. This prevents user enumeration attacks.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this only happen if the user has user enumeration protection enabled?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use this custom flow without enabling strict enumeration protection first. That has a lot of holes though: UserProfile is unprotected, and an attacker could just manually send FAPI requests.

I implemented it with them separate because it seems like some people ask for this as an alternative to strict enumeration protection, it's like "kind of enumeration protection". Also it's possible that some customers could like the way it does verification upfront.

@dmoerner
Copy link
Copy Markdown
Contributor Author

This looks great, thank you so much for the suggestions @alexisintech! It all makes sense and looks clear to me.

@alexisintech alexisintech marked this pull request as ready for review March 23, 2026 16:49
@alexisintech alexisintech requested a review from a team as a code owner March 23, 2026 16:49
@alexisintech alexisintech merged commit 427814d into main Mar 23, 2026
8 checks passed
@alexisintech alexisintech deleted the daniel/sign-up-if-missing-custom-flow branch March 23, 2026 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants