You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3770a78
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/guide/auth.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -220,9 +220,9 @@ When auth is active, Void configures Better Auth with these conventions:
220
220
221
221
Auth sessions live in the same database system as the rest of the app. `AUTH_KV` is no longer used.
222
222
223
-
On Void Cloud, Void auto-creates `BETTER_AUTH_SECRET` for auth-enabled apps if you have not set `BETTER_AUTH_SECRET` yourself through project secrets.
223
+
Both Void Cloud and `void deploy --platform cloudflare` automatically ensure a persistent `BETTER_AUTH_SECRET` for auth-enabled apps. An existing secret is preserved; when it is missing, deploy generates it once and stores it through the target's encrypted secret storage. On Cloudflare, the value is sent to `wrangler secret put` over stdin and inherited by later Worker versions.
224
224
225
-
Localhost dev uses a built-in fallback secret automatically. Outside the managed Void Cloud deploy flow, set `BETTER_AUTH_SECRET` yourself.
225
+
Localhost dev uses a built-in fallback secret automatically. If you deploy without the Void CLI, including bare `vite build && wrangler deploy`, set and inherit`BETTER_AUTH_SECRET` yourself.
Copy file name to clipboardExpand all lines: docs/guide/deployment.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -174,6 +174,6 @@ Connect the repository to your project once with `void github connect <project>
174
174
175
175
## Other Targets
176
176
177
-
To deploy directly to your own Cloudflare account, select Cloudflare during `void init` or run `void deploy --platform cloudflare`. Void automatically creates or adopts the D1/KV/R2/Queues/Hyperdrive resources your app needs, then continues the deploy. This uses your local wrangler auth and root `wrangler.jsonc` -- pin an account (`account_id` or `CLOUDFLARE_ACCOUNT_ID`) and keep real secrets in `wrangler secret put` rather than `.env`. `wrangler login` is enough to authenticate, with one exception: provisioning a **Hyperdrive** config for the first time needs `CLOUDFLARE_API_TOKEN`, because wrangler exposes no machine-readable Hyperdrive list for Void to check against (an already-provisioned Hyperdrive app deploys fine under `wrangler login`). In v1 it deploys **full Void apps on the Cloudflare Workers target** (D1/KV/R2/Queues/Hyperdrive; auth and ISR on D1/SQLite); framework SSR (TanStack Start, React Router, vinext, SvelteKit, Nuxt, Analog, Astro), static/SPA/SSG apps (including `output: "static"`), WebSocket/Durable Object apps (`*.ws.ts`), a custom `migrations_pattern`, `--skip-build`, `node`/`bun`/`deno` targets, and PostgreSQL apps with auth all fail closed with guidance. For auth apps, run `void db generate`; it automatically includes the production Better Auth schema, and deploy validates and applies the checked-in migration to remote D1. Avoid concurrent first deploys from different machines or CI runners because the provisioning lock is local to one config path. See the [Cloudflare integration guide](../integrations/cloudflare.md#deploy-to-your-own-cloudflare-account) for the full walk-through and scope.
177
+
To deploy directly to your own Cloudflare account, select Cloudflare during `void init` or run `void deploy --platform cloudflare`. Void automatically creates or adopts the D1/KV/R2/Queues/Hyperdrive resources your app needs, then continues the deploy. For auth-enabled apps it also preserves an existing remote `BETTER_AUTH_SECRET`, or creates and stores one once when missing. This uses your local wrangler auth and root `wrangler.jsonc` -- pin an account (`account_id` or `CLOUDFLARE_ACCOUNT_ID`) and keep other real secrets in `wrangler secret put` rather than `.env`. `wrangler login` is enough to authenticate, with one exception: provisioning a **Hyperdrive** config for the first time needs `CLOUDFLARE_API_TOKEN`, because wrangler exposes no machine-readable Hyperdrive list for Void to check against (an already-provisioned Hyperdrive app deploys fine under `wrangler login`). In v1 it deploys **full Void apps on the Cloudflare Workers target** (D1/KV/R2/Queues/Hyperdrive; auth and ISR on D1/SQLite); framework SSR (TanStack Start, React Router, vinext, SvelteKit, Nuxt, Analog, Astro), static/SPA/SSG apps (including `output: "static"`), WebSocket/Durable Object apps (`*.ws.ts`), a custom `migrations_pattern`, `--skip-build`, `node`/`bun`/`deno` targets, and PostgreSQL apps with auth all fail closed with guidance. For auth apps, run `void db generate`; it automatically includes the production Better Auth schema, and deploy validates and applies the checked-in migration to remote D1. Avoid concurrent first deploys from different machines or CI runners because the provisioning lock is local to one config path. See the [Cloudflare integration guide](../integrations/cloudflare.md#deploy-to-your-own-cloudflare-account) for the full walk-through and scope.
178
178
179
179
To deploy to Node.js, Bun, or Deno instead of Cloudflare, set [`target`](../reference/config.md) in `void.json`. This builds a standalone server you can run anywhere, including Docker, Railway, and Fly.io. These targets do not have access to Void platform features such as D1, KV, R2, built-in auth, Workers AI, or cron scheduling. See the [Node.js, Bun, and Deno guide](../integrations/nodejs-bun-deno.md).
Copy file name to clipboardExpand all lines: docs/guide/env-vars.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -152,6 +152,8 @@ void secret delete STRIPE_KEY
152
152
153
153
Remote secrets count as "present" for deploy validation — `void deploy` checks both `.env*` and the remote secret list before uploading.
154
154
155
+
For auth-enabled apps, both Void Cloud and `void deploy --platform cloudflare` manage `BETTER_AUTH_SECRET` automatically: they preserve an existing encrypted secret and generate one only when missing. Other secrets remain user-managed. Bare `vite build && wrangler deploy` does not provide this lifecycle; set `BETTER_AUTH_SECRET` with Wrangler and declare it in `secrets.required` yourself.
156
+
155
157
## Defaults
156
158
157
159
Schema defaults from `defineEnv({ PORT: number().default(3000) })` flow into:
-**`CLOUDFLARE_API_TOKEN` is required to provision a Hyperdrive config for the first time.**`wrangler login` covers every other resource, but wrangler exposes no machine-readable Hyperdrive list, so Void checks whether the config already exists over the Cloudflare REST API -- which an OAuth session cannot authenticate. Without a token automatic provisioning stops **before** touching your account rather than risk minting a duplicate config. Either export `CLOUDFLARE_API_TOKEN` (with Hyperdrive edit permission), or create the Hyperdrive config yourself and add its id to the `hyperdrive` binding in `wrangler.jsonc` -- deploying an **already-provisioned** Hyperdrive app needs no token and works under `wrangler login` alone.
240
240
-**Docker**, if your app uses the sandbox -- the build needs it locally.
241
241
242
-
**What it does** (in order): settles the app class (a full Void app on the Cloudflare Workers target -- see [scope](#scope-and-limitations)) before any account operation; pins the account and confirms wrangler auth; automatically creates or adopts every inferred resource; **builds**; then, against the artifact the build actually emitted, warns on plaintext vars, gates on missing required secrets, checks the auth schema, and validates migrations; then applies remote D1 migrations for SQLite apps (and verifies none remain pending); then runs `wrangler deploy` on exactly the artifact it verified.
242
+
**What it does** (in order): settles the app class (a full Void app on the Cloudflare Workers target -- see [scope](#scope-and-limitations)) before any account operation; pins the account and confirms wrangler auth; automatically creates or adopts every inferred resource; **builds**; then, against the artifact the build actually emitted, warns on plaintext vars, gates on missing required secrets, checks the auth schema, and validates migrations; for auth apps, preserves the existing remote `BETTER_AUTH_SECRET` or creates and verifies one when missing; then applies remote D1 migrations for SQLite apps (and verifies none remain pending); then runs `wrangler deploy` on exactly the artifact it verified. The generated config marks the auth secret as required so Wrangler inherits it into the uploaded Worker version.
243
243
244
244
Note that **the build runs before the secret, auth-schema, and migration gates** -- those gates read the real emitted worker, so there has to be one to read. A missing production secret or a bad migration is therefore reported _after_ resources may have been provisioned and the build has run, which is worth knowing if your build hooks are slow or have side effects. Remote D1 migrations and the worker upload still run only once every ground-truth gate has passed, so a failed gate does not alter the database schema or live worker.
245
245
246
246
**Trust boundary: the build runs your project's code.** Exactly like the manual `vite build && wrangler deploy` below, this backend runs your project's build -- your config, every Vite plugin, and every build dependency -- with filesystem access before the credentialed deploy. Deploy narrows what that build can quietly change: it runs the build with your Cloudflare credentials scrubbed, verifies the emitted `wrangler.json` against a pre-build snapshot of your account, name, and binding identities, and checks that the wrangler CLI it is about to run with your token was not modified during the build. Those checks catch a build that tampers with the deploy target or the uploader. They do not sandbox the build itself, so a fully-compromised build dependency remains a trust boundary -- the same one you accept running `vite build` by hand. Vet your dependencies as you would for any deploy; stronger build isolation is future work.
247
247
248
-
Provisioning is automatic and **idempotent**. Void reads existing ids first, adopts matching resources when possible, creates anything missing, and writes the resolved ids into your root `wrangler.jsonc`. Queues carry no id in the config, so Void checks each one against your account with `wrangler queues info` and creates it when absent. The former `--provision` flag is still accepted for backwards compatibility but is no longer needed.
248
+
Provisioning is automatic and **idempotent**. Void reads existing ids first, adopts matching resources when possible, creates anything missing, and writes the resolved ids into your root `wrangler.jsonc`. Queues carry no id in the config, so Void checks each one against your account with `wrangler queues info` and creates it when absent. Auth-enabled apps similarly reuse an existing `BETTER_AUTH_SECRET`; they generate a 32-byte random value only when the remote secret is absent, never once per deploy. The former `--provision` flag is still accepted for backwards compatibility but is no longer needed.
249
249
250
250
#### Scope and limitations
251
251
@@ -263,7 +263,7 @@ Provisioning is automatic and **idempotent**. Void reads existing ids first, ado
263
263
-**Avoid concurrent first deploys from different machines or CI runners.** The provisioning lock is per local config path and does not coordinate across hosts. Resource adoption makes later deploys idempotent, but two first deploys racing the same account could create duplicate resources whose names are not account-unique. Commit the updated `wrangler.jsonc` when practical so CI starts with the resolved ids.
264
264
-**Your `wrangler.jsonc` is rewritten on provision.** Wrangler preserves your comments but normalizes the whole file's indentation when it writes the new ids -- expect that in the diff.
265
265
-**Portable `.env` values ship as plaintext.** The build bakes `.env` and `.env.production` into the worker's `vars`. It excludes `.env.local` and `.env.production.local`; outside this deploy path, Void retains Vite's normal dotenv loading behavior. A value also present in the shell environment is stripped back out, so a var you `export` in CI does not get baked in. Move real secrets to `wrangler secret put <NAME>` so they are never written into `wrangler.json`. Deploy warns on likely-plaintext secrets -- by key name, and by value shape for credential-bearing connection URLs such as `DATABASE_URL` -- and hard-blocks on missing required secrets.
266
-
-**First deploy of a new worker.**A worker that has never been deployed has no remote secrets to list yet, so the secret gate prints the still-unset required key names and the `wrangler secret put <NAME>` commands that bootstrap them on the draft worker (or add a value to `.env` / `.env.production` and rerun).
266
+
-**First deploy of a new worker.**Void automatically bootstraps `BETTER_AUTH_SECRET` on the draft Worker for auth-enabled apps. Other required secrets still need to be created with the `wrangler secret put <NAME>` commands printed by the secret gate (or supplied as non-secret plaintext vars when appropriate).
267
267
268
268
The manual steps below are the by-hand equivalent -- reach for them when you want to manage resources and `wrangler.jsonc` yourself.
269
269
@@ -319,6 +319,12 @@ Create `wrangler.jsonc` in your project root with the resource IDs from step 1:
319
319
320
320
Only include the bindings your app actually uses. You can also add service bindings, custom routes, environment overrides, and any other standard wrangler fields -- they all flow through to the build output. You don't need `main` or `assets` -- those are set by the plugin.
321
321
322
+
For an auth-enabled app deployed by hand, also add `"secrets": { "required": ["BETTER_AUTH_SECRET"] }` so Wrangler inherits the secret into replacement Worker versions, then create it before the first deploy:
323
+
324
+
```bash
325
+
wrangler secret put BETTER_AUTH_SECRET
326
+
```
327
+
322
328
#### 3. Run migrations
323
329
324
330
If your app uses D1, apply migrations before deploying:
Copy file name to clipboardExpand all lines: docs/reference/cli.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -332,7 +332,7 @@ Prerequisites:
332
332
-`--project`, `--dir` and `--spa` are **not supported** with `--platform cloudflare` either, and are rejected rather than ignored: no Void project is resolved on this path, and it uploads the worker your build emits rather than a static directory.
333
333
- Local Docker is required to build apps that use the sandbox.
334
334
335
-
What it does, in order: settles the app class before any account op (v1 supports **full Void apps on the Cloudflare Workers target** -- worker-bearing apps running Void's routing, with D1/KV/R2/Queues/Hyperdrive and, on D1/SQLite, auth + ISR; framework SSR of every kind, static/SPA/SSG apps, node/bun/deno targets, and PostgreSQL apps with auth or with checked-in migrations all fail closed with guidance), pins the account and checks auth, automatically provisions missing resources, **builds**, then gates on the artifact the build emitted — production secrets checked against the build's effective mode/envDir, the auth schema, and migration validation — then applies remote D1 migrations for SQLite apps (verifying the applied set equals the validated set and none remain pending), and finally runs `wrangler deploy` on exactly the verified artifact. Auth apps must ship checked-in migrations that produce the Better Auth schema — the managed platform's runtime auth-migration step does not run on this backend.
335
+
What it does, in order: settles the app class before any account op (v1 supports **full Void apps on the Cloudflare Workers target** -- worker-bearing apps running Void's routing, with D1/KV/R2/Queues/Hyperdrive and, on D1/SQLite, auth + ISR; framework SSR of every kind, static/SPA/SSG apps, node/bun/deno targets, and PostgreSQL apps with auth or with checked-in migrations all fail closed with guidance), pins the account and checks auth, automatically provisions missing resources, **builds**, then gates on the artifact the build emitted — production secrets checked against the build's effective mode/envDir, the auth schema, and migration validation — preserves an existing remote `BETTER_AUTH_SECRET` or creates and verifies one for an auth app when missing, then applies remote D1 migrations for SQLite apps (verifying the applied set equals the validated set and none remain pending), and finally runs `wrangler deploy` on exactly the verified artifact. The generated config inherits the persistent auth secret into the new Worker version. Auth apps must ship checked-in migrations that produce the Better Auth schema — the managed platform's runtime auth-migration step does not run on this backend.
336
336
337
337
The build deliberately comes **before** the secret, auth-schema, and migration gates, because those gates inspect the real emitted worker rather than a prediction of it. A missing secret or a bad migration surfaces after the build has run — relevant when a build is expensive or has side effects. Remote D1 migrations run only once every gate has passed, so a failed gate mutates nothing remote.
338
338
@@ -341,7 +341,7 @@ Every deploy automatically ensures that the D1 database, KV namespaces, R2 bucke
341
341
-**Avoid concurrent first deploys from different machines or CI runners.** The provisioning lock is per local config path and does not coordinate across hosts. Resource adoption makes later deploys idempotent, but two first deploys racing the same account could create duplicate resources whose names are not account-unique. Commit the updated `wrangler.jsonc` when practical so CI starts with the resolved ids.
342
342
-**Your `wrangler.jsonc` is rewritten.** When wrangler writes the new ids, it preserves your comments but normalizes the whole file's indentation — expect that in the diff.
343
343
-**Portable `.env` values ship as plaintext.**`.env` and `.env.production` are baked into the worker's `vars`; `.env.local` and `.env.production.local` are excluded from this deploy build. A value also present in the shell environment is stripped back out. Move real secrets to `wrangler secret put <NAME>` so they are not committed into `wrangler.json`. Deploy warns on likely-plaintext secrets and hard-blocks on missing required secrets.
344
-
-**First deploy of a not-yet-deployed worker:**its remote secrets can't be listed yet, so the secret gate prints the required key names and the `wrangler secret put <NAME>` commands to bootstrap them on the draft worker before deploying (or add a value to `.env` / `.env.production` and rerun).
344
+
-**First deploy of a not-yet-deployed worker:**Void bootstraps `BETTER_AUTH_SECRET` automatically for auth-enabled apps. The secret gate still prints `wrangler secret put <NAME>` commands for any other required secrets that need to be added to the draft Worker.
345
345
346
346
See the [Cloudflare integration guide](../integrations/cloudflare.md#deploy-to-your-own-cloudflare-account) for the full walk-through.
0 commit comments