Skip to content
Orvanov0.2.0

Email codes

With an email code, a user types their email, gets a 6 digit code by email, and types the code into your app to sign in. It needs no links, so it works the same in every app on every platform, with no deep link setup: the easiest passwordless sign in for a Flutter app. If the email has no account yet, the code creates one.

This guide starts from a finished quickstart running against Orvano on your machine; the code lands in the local inbox at http://localhost:8025.

account.createEmailCode needs no session, and answers the same way whether or not the email has an account.

await orvano.account.createEmailCode({ email })

Pass createUser: false to send codes only to existing users. A code works for 10 minutes. Sending a new one makes the older one stop working.

Open http://localhost:8025: you should see “Your sign in code for” your project, with the 6 digits.

const { user, isNewUser } = await orvano.client.signInWithEmailCode(email, code)

The user is signed in and their email is verified. As with magic links, isNewUser tells you the code created the account, and the account has no password yet.

A wrong code gets invalid_code. After 5 wrong tries the code stops working, and an expired or unknown code gets the same answer, so tell the user to ask for a new code. Help them type it: an inputmode="numeric" field with autocomplete="one-time-code" lets phones fill it in from the email.