Lesson 5 of 110 of 6 steps

Lesson 5 · about 30 minutes

Sign-in codes and emails

No passwords to remember or leak. People type their email, get a six-digit code, and they're in. Your partner or team joins with an invite. And your app can send confirmations and reminders from your own address.

Passwordless sign-in with emailed codes, invite keys for families and teams, and transactional email from your domain through Cloudflare Email Service. Email to anyone needs Workers Paid ($5/month).

Sign-in with six-digit codes sent by email, stored only as a hash. Codes last 15 minutes, any code that hasn't run out works, and wrong guesses and requests are limited. Sessions use HttpOnly cookies, and invite keys come with roles. Email goes out through Cloudflare Email Service; sending to anyone other than yourself needs Workers Paid.

How much have you built before?
This lesson's wording changes to match.
Free plan: email to yourself$5/month: email to anyone
From hello@yourapp.com
Your sign-in code is 482 913
It works for 15 minutes.

No passwords, ever.

What you'll make

  • Sign-in with an emailed six-digit code
  • Invites for a partner, family or team
  • Email sent from your own address

You'll need: an app with a database (lesson 4) and, to email other people, your own domain on Cloudflare.

1

Decide who signs in

Who should see what? A family log might be "us two, plus grandparents who can only look". A club site might be "any member". Say it plainly:

Say to your agent
Only my partner and I can add entries. Grandparents can look but not change anything. Nobody else can see it.

Your agent turns that into rules the server checks on every request, not just hidden buttons.

2

Sign in with an emailed code

Say to your agent
Add sign-in with a six-digit code sent by email. No passwords. Codes should run out after 15 minutes and wrong guesses should be limited.
From your app
Your sign-in code is 482 913
It works for 15 minutes.

The code types itself in, as it would from the email.

You should see

An email with a code, a box to type it in, and you're signed in, staying signed in on that phone.

While testing on your computer, the code shows on screen instead of being emailed, so you can try it before email is set up.

Two emails arrived
Usually a double tap or "send again". Any code that hasn't run out works, so use either. Ask your agent to make the button wait a few seconds before "send again" appears.
"That code isn't right"
Check it's the newest email, typed without spaces. After five wrong tries, ask for a new code.
3

Email needs your own domain

To send email, your app needs an address like hello@yourapp.com, which means your own domain on Cloudflare (lesson 10 covers getting one). Cloudflare adds the records that prove the email is really from you.

The cost, from Cloudflare's docs (November 2026): on the free plan you can only send to your own verified addresses. Sending to anyone else (sign-in codes for other people, customers) needs Workers Paid, $5 a month.

Say to your agent
Set up sending email from hello@ my domain. Tell me what it costs before you turn anything on.
4

Send a test to yourself first

Before any real person gets an email from your app, you get one. Check it arrives, isn't in spam, and reads well.

Say to your agent
Send me a test sign-in email. Don't email anyone else yet.

House rule: your agent asks before the first email to any real address. Every time.

5

Invite your partner or team

Say to your agent
Let me invite my partner with a short invite key, and family members as look-only.

You'll get a short key (like blue-ivy-yew-quill-4485) or a link and QR code to share. Invites run out after a while, and you can take access away from Settings.

I want to start again with a new key
Making a new key signs everyone else out. Your agent should warn you before doing it.
6

Other emails your app can send

The same setup sends booking confirmations, quotes, receipts, reminders and weekly summaries. Anything that isn't essential gets a one-tap unsubscribe.

Say to your agent
When someone books, send them a confirmation from hello@ my domain, with the time and a link to cancel.
Lesson 5 doneYou just added sign-in with an emailed code, invites, and email from your own address.
Next up · lesson 6, about 20 minutesMake sure every phone picks up your changes, with a 'new version ready' bar.

Did it work?

Tick these off. They're saved in this browser, so you can come back later.

  • I signed in with a code from my email
  • Codes run out, and wrong guesses are limited
  • My partner or team joined with an invite
  • The first emails went to me before anyone else