All of the guide

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:

  1. builds the Worker and the browser bundle,
  2. creates the resources your code uses, which it finds from your imports: D1 for void/db, with read replicas as void.config.ts asks, a Durable Object for the void/live stream, KV for void/kv, the session secret (BETTER_AUTH_SECRET) for void/auth, and email sending for void/email (below),
  3. applies the database migrations in db/migrations/, the auth tables' included,
  4. 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/:

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.