All of the guide

Signing in

No passwords: a code by email, or a passkey, and either one makes the account. Both come from Better Auth, which Void sets up for you (void/auth: its routes under /api/auth, its tables in D1, the session cookie), and which auth.ts configures. The pages are Turbo forms, like any other (Forms).

Part Where
Email codes and passkeys on, passwords off auth.ts: Better Auth's emailOTP and passkey plugins
Sending the code src/email.ts, with Void's email; the sender is email.from in void.config.ts
The forms and the passkey list routes/account/ and routes/login.tsx; what they share is src/sign-in.ts, src/passkeys.tsx and src/components/account.tsx
Six digits send the form otp_input_controller.ts
Signing up with a passkey, and confirming the address after auth.ts: the passkey plugin's registration, and two hooks; routes/account/confirm/
Passkeys, in a browser and in the apps bridge/passkey_controller.ts, with PasskeyComponent.swift and PasskeyComponent.kt in the apps
The auth tables db/migrations/, written by vp exec void db generate from auth.ts

The email code

/account signed out shows the email form. POST /account/otp/send asks Better Auth to send a code, and answers with a Turbo Stream that replaces the panel with the code's form. POST /account/otp/verify signs in with the code: a wrong one answers 422 and Better Auth's message ("Invalid OTP", then "Too many attempts" after three), the right one redirects where the form said. The database keeps a hash of the code, never the code.

Both forms call Better Auth's own routes, /api/auth/email-otp/send-verification-otp and /api/auth/sign-in/email-otp, through getAuth(c).handler (authRoute in src/sign-in.ts), and pass on the session cookie the sign-in sets. Deployed, those routes limit each client IP, to 3 codes and 3 tries a minute (the emailOTP plugin's); a call to getAuth(c).api skips the limit, and anyone could have the app send codes to any address without end.

Where the form sends you next is a path on this site only. safeRedirect reads it with new URL against the request, as a browser would: //host, /\host and /<tab>/host are all other sites to a browser.

A message's author shows on the public messages page, so it is the user's name, never their email address. Signing in with a code gives no name, so those messages show no author.

The code field has autocomplete="one-time-code", so the phones offer the code from the email or message they got, and its Stimulus controller sends the form when the sixth digit arrives. It closes the keyboard and scrolls the page to its top first. The signed-in account page keeps the scroll the page had: the apps reload the same address, and a browser's Turbo refreshes it (turbo-refresh-scroll). On a phone the keyboard had scrolled the page to keep the field in view, and closing it doesn't scroll it back, so the account would open with "Signed in as" under the top bar.

Better Auth sends the email in the background, after answering, so the form says the code is on its way even when sending failed. The server's log says why.

Void's email

The code goes out through sendEmail from void/email, in src/email.ts:

Void turns email on because a file it scans imports void/email: src/, routes/, middleware/ and a few others, but not auth.ts, at the root. So the sending lives in src/email.ts, and auth.ts loads it inside the hook with await import(…). Imported at the top of auth.ts instead, it breaks vp test: Void reads auth.ts by itself to write the auth tables' schema, and under the tests void/email's address checker, CommonJS, can't load.

Passkeys

In a browser, the passkey controller uses Better Auth's WebAuthn client (src/auth-client.ts). The email field's autocomplete="username webauthn" lets the browser offer saved passkeys as you click into it. The dev server's name (hotwire.localhost) is a domain to WebAuthn, which an address made of numbers is not, so a passkey can be tried on a dev server, by hand: add one on the account page, sign out, and sign in with it, with the Mac's Touch ID or a phone.

In the phone apps the same controller is a bridge component, passkey. A bridge component's controller loads only in an app that has its native half; this one has work to do in a browser too, so it says static get shouldLoad() { return true }, and this.enabled tells it which half runs. Its web half fetches the options from Better Auth in the web view, where the session cookie is; the native half asks the system for the passkey (AuthenticationServices on iOS, Credential Manager on Android); the web half posts the answer back to Better Auth.

The system gives a passkey only to an app that the page's domain names: the files in routes/.well-known/.

When the system refuses, the page shows its reason ("iOS gave no passkey (1004): Application with identifier … is not associated with domain …"; "Android gave no passkey (…): …").

The account's passkeys can be renamed in place (a Turbo Frame) and removed. One that another device removed first is dropped from the page, as that device's broadcast would have done, instead of failing. Each change is also broadcast to the user's own live topic, user:<id>, which src/live.ts lets only that user follow, so their other open pages and apps update (Live updates).

Void ties a live connection to whoever opened it, and only they can change what it follows. A page keeps its one connection across Turbo visits, so one opened signed out can't follow user:<id> after signing in. The layout says who each page is for (<meta name="live-owner">), and src/live-stream-source.ts opens the connection again when that changes.

Signing up with a passkey

Signed out, "Sign up with Passkey" makes an account for the address in the email field, with a passkey the device makes, and signs it in: no email, no code. It is the passkey plugin's own registration, with requireSession: false in auth.ts:

Nothing proves the address is theirs, so the account is emailVerified: false. The account page says "Not confirmed" and asks: POST /account/confirm/send emails a code to the account's own address, never one the form names, and POST /account/confirm/verify confirms it with Better Auth's /api/auth/email-otp/verify-email. Signed in, so the passkey stays.

Until then the account is whoever proves the address. When a sign-in code proves an unverified address, Better Auth ends the account's sessions, as the person with the mailbox may not be who made the account. Its passkey plugin leaves the passkeys, so databaseHooks.user.update.after in auth.ts removes them: otherwise someone could make an account for your address before you do, and keep a passkey to it after you sign in.

With requireSession off, the plugin no longer asks that a signed-in person's session be fresh (a day, Better Auth's freshAge) before it adds a passkey to their account. hooks.before in auth.ts asks it again ("Sign in again to add a passkey."), as a passkey outlives the session that added it.

Deleting the account

"Delete this account", at the foot of the account page, asks first, in the page: its link loads the question into its own frame (GET /account/delete), so it is the same in a browser and in both apps, with no dialog of the system's. "Yes, delete my account" is POST /account/delete, which calls Better Auth's /api/auth/delete-user (user.deleteUser in auth.ts): the account and its sessions go, and the page is the signed-out account page again. The form leaves the frame (data-turbo-frame="_top"), as its answer is a whole page.

Checking it

vp test                                  # the routes (src/routes.test.tsx), and auth.ts on the real Better Auth (src/auth.test.ts)
vp run flows:web otp-sign-in             # the flow in a browser, against your dev server
vp run flows:web passkey                 # a passkey in a browser, with a fingerprint reader the flow touches
vp run flows:ios passkey                 # a passkey in the iOS app, with the simulator's Face ID
vp run flows:android passkey             # a passkey in the Android app, with the test keeper
vp run flows:web passkey-sign-up         # signing up with a passkey; flows:ios and flows:android too
curl https://hotwire.localhost/.well-known/apple-app-site-association   # what iOS asks, on port 443
vp run test:all                          # it in a browser and in both apps, on the test server

flows/otp-sign-in.yaml signs in with a wrong code, then the right one, and signs out: in a browser, and on the Account tab of both apps, where "Sign out" is in a native menu. It reads the code where you would, in Void's inbox: flows/otp.js gets the inbox with Void's token (.void/dev-trigger-token, which the tasks pass to Maestro), and takes the newest code sent to the address. The test runs' server is a dev server for this reason (Testing).

flows/passkey.yaml adds a passkey, signs out and signs in with it: in a browser and in both apps. A passkey needs a fingerprint or a face, which no flow has. So the command that runs a flow has a reader for its device (tasks/reader.ts), and the flow touches it with a step of its own (flows/touch.js) after it presses the button.

flows/passkey-sign-up.yaml signs up with a passkey, confirms the address with the code in Void's inbox, signs out and signs in with the passkey, and deletes the account, in the same three places: nothing of a run stays on the server. The two flows share what the system asks and the touch (flows/parts/passkey-make.yaml, passkey-use.yaml).

src/auth.test.ts asks auth.ts itself, on Better Auth as it is installed with its tables in memory, with a passkey the test makes as a device does (a key pair, and what WebAuthn has a device send): signing up, the address that has an account, the sign-in code that takes an unconfirmed account and its passkeys, confirming from the account, and the session that is too old to add a passkey.

Where a test is about what comes after signing in, its account and session come from Better Auth's own test helpers (testUtils, in better-auth/plugins: createUser, saveUser, getAuthHeaders), with no code and no email. The test adds that plugin to its own instance, and auth.ts never has it: the helpers make a session for any account, and Better Auth's source says to keep them out of an app's config. So no server has them, local or deployed, and no route stands in for them, with a secret or without: a flow signs up and signs in as anyone does, and reads a code where the email goes, in Void's inbox.

The same flow runs against a deployed app, in a browser and in the iOS app, where Apple's servers read the domain's file (Deploying). What nothing has checked yet: a passkey kept by Google Password Manager, with a Google account, in the Android app on a deployed address; and either app on a phone.

What breaks

Symptom Cause
"Sign in with Passkey" and "Add passkey" do nothing in a browser, and the console is empty The controller is a bridge component, which loads only in an app with its native half: one with a browser half overrides shouldLoad
In the iOS app: "iOS gave no passkey (1004): Application with identifier … is not associated with domain …" The name did not name the app when iOS asked, which it does as the app is installed. Nothing answered on the Mac's port 443 (no dev server was running, or another program has the port), or the app was built under another team than APPLE_TEAM_ID. Start the dev server, then vp run ios
In the Android app on a dev server, "Add passkey" opens "Create passkey on another device?" Nothing on the emulator keeps a passkey for a name on your Mac: vp run android installs the example's test keeper and sends new passkeys to it ("Test passkeys" under Settings, "Passwords, passkeys & accounts")
"That address has an account: sign in to it." under "Sign up with Passkey" The address signed up or signed in before: sign in with its passkey, or with a code
After signing in with a code, the account's passkeys are gone The account was made with a passkey and its address never confirmed: a sign-in code then takes the account, by design. Confirm the address from the account page
"Sign in again to add a passkey." The session is older than a day (Better Auth's freshAge)
The form says the code is on its way, and none comes Better Auth sends in the background: read the server's log
"neither SEND_EMAIL nor __VOID_PROXY is available", and no inbox printed when the dev server starts Nothing Void scans imports void/email: keep it in src/
"'from' is required" in the log No email.from in void.config.ts
vp test stops before any test: "exports is not defined", in email-validator auth.ts imports void/email at its top: load it inside the hook
"Too many requests. Please try again later." on the email form, deployed Better Auth's limit for the client's IP: 3 codes and 3 tries a minute
No limit on sending codes, deployed The route calls getAuth(c).api, which skips it: call Better Auth's route (authRoute)
"Missing Better Auth secret" from vp preview A production build needs BETTER_AUTH_SECRET in .env; a dev server has Void's own
"Content missing" where "Delete account" was, after deleting The form answered inside its frame: it needs data-turbo-frame="_top", as its answer is the signed-out page, which has no such frame
A passkey changed on one device doesn't show on another The page doesn't follow user:<id>, or src/live.ts refuses it
getOTP of Better Auth's test helpers gives 43 characters, not the 6-digit code The app keeps its codes hashed (storeOTP: "hashed"), and getOTP gives what is kept: read the email, as src/auth.test.ts does (what src/email.ts is given)
In the iOS app, signed in, the page opens scrolled, its top under the bar The reload keeps the scroll the keyboard left: scroll to the top as the code is sent (otp_input_controller.ts)
"live: connection owner mismatch" in the log, after signing in or out The page's live connection was opened by someone else: it must be opened again (live-owner)
In the phone apps, signed in on Account, the Messages tab still says "Sign in with Passkey or Email OTP" Each tab is a web view with the page it loaded, and nothing tells it that the session changed: it shows it when it loads again. The flow checks the signed-in messages in a browser only