Deploying
The app runs on Cloudflare Workers, in your own Cloudflare account.
vp run deploy --platform cloudflare
The first time, Void asks you to sign in to Cloudflare in the browser, and to pick an account if you have more than one. Then it:
- builds the Worker and the browser bundle,
- creates the resources your code uses, which it finds from your imports: D1 for
void/db, with read replicas asvoid.config.tsasks, a Durable Object for thevoid/livestream, KV forvoid/kv, the session secret (BETTER_AUTH_SECRET) forvoid/auth, and email sending forvoid/email(below), - applies the database migrations in
db/migrations/, the auth tables' included, - uploads and deploys, and prints the URL (
https://<name>.<your-subdomain>.workers.dev).
Later deploys are vp run deploy. The Worker's name comes from "name" in package.json.
Void writes the resource ids to void.lock.json. Commit it, so the next deploy, from your machine or from
CI, reuses the same resources instead of creating new ones. (This repository ignores the example's lock file,
because the example is copied by others.)
Give the first requests a few seconds. Right after the first deploy, the example answered a request or two with errors before settling.
Secrets and settings
Declare environment variables in env.ts, put local values in .env, and set production secrets with
vp exec void secret put NAME. See https://void.cloud/guide/env-vars.
Email and passkeys
The sign-in code goes out by email (Signing in). On your own Cloudflare account it is sent from
email.from in void.config.ts, which must be an address on a domain the account can send from: the example's
mail.example.com stands for yours, so change it first. The first deploy shows the email setup it would make for that
domain and asks; declined, the app deploys without email, and every code fails to send (the Worker's log says so).
See Void's email domains guide.
Deployed, Void limits auth requests per client IP with Better Auth's defaults, such as 3 email codes and 3 tries
a minute (Void's auth guide). Only Better Auth's routes under /api/auth count, so
the example's sign-in forms call those (Signing in). Each Worker instance keeps its
own count.
Signing up with a passkey needs no email (Signing in), so it works on a deploy that has no mail domain yet; only confirming the address waits for one.
Checking the deployed app
A deployed app is no dev server, so its address is given: HOTWIRE_URL, to the flows and to the tasks that build
the phone apps.
HOTWIRE_URL=https://<your app> vp run flows:web passkey-sign-up # in a browser
HOTWIRE_URL=https://<your app> vp run ios # the iOS app, built for that address…
HOTWIRE_URL=https://<your app> vp run flows:ios passkey-sign-up # …and the same flow in it
The flow signs up with a passkey, signs out, signs in with it and deletes its account; it leaves out confirming the
address, as a deployed app has no inbox for it to read (Testing). No pass is kept. Both ran
against the example's own deploy, on a workers.dev address.
In the phone apps a passkey needs the domain to name the app (Signing in), with the files
in routes/.well-known/:
- iOS. The entitlement takes the domain from the address the app is built with, and for any name that is not
on your Mac it has no
?mode=developer: Apple's servers read the domain's file. On a simulator the build is signed by no one, so the placeholder team on both sides (XXXXXXXXXX) passes, as it did here. For a phone, set yours:vp exec void secret put APPLE_TEAM_ID, and build the app signed by that team. - Android.
vp run androidfor an address that is not on your Mac takes the example's test keeper off, and Google Password Manager keeps the passkeys. It needsvp exec void secret put ANDROID_SHA256_FINGERPRINT, the SHA-256 of the certificate that signs the build (keytool -list -v -keystore ~/.android/debug.keystorefor a debug build), which the domain's file then names, and a Google account on the device: without one Android offers only "Create passkey on another device?". This has not run to a pass from the example yet.
Taking a deployment down
Void has no command for this. Use cf, Cloudflare's CLI, which is installed with Void:
vp exec cf workers delete <name> --force
vp exec cf d1 delete <database-id> # the id is in void.lock.json
Deleting the Worker also deletes the Durable Objects it defines, and with them the live stream.
Before you deploy a public app
The example lets anyone post without signing in, and every message is a D1 write. D1's free-tier write
limit is shared by the whole Cloudflare account, so an open form can use it up for your other apps too. Ask for
sign-in before the form takes a message (requireAuth, Signing in), or add a rate limit, before
you deploy a form for real.