Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 82 additions & 1 deletion docs/integrations/cloudflare.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,86 @@ export CF_ACCESS_READINESS_ORIGIN="https://app.example.com"

Set this variable in the shell or CI environment running `void deploy`. Use an exact HTTPS origin for a hostname you control that serves this Worker; Void sends your Access credentials there.

### Pull request previews

Give each pull request its own URL with [Cloudflare Previews](https://developers.cloudflare.com/workers/previews/). A preview belongs to the same Worker but never receives production traffic.

```sh
void deploy --platform cloudflare --preview pr-64 --json # create or update
void project preview delete pr-64 --platform cloudflare # remove
```

Deploy production once first and set the Worker name (`cloudflare.name`, or `name` in `wrangler.jsonc`). The token needs **Workers → Editor**, since the Worker already exists, and `CLOUDFLARE_ACCOUNT_ID` pins the account. The preview job runs the pull request's code with this token, which can also deploy production. Pull requests from forks and Dependabot get no preview.

This workflow deploys a preview on every push, comments its URL once, and deletes it when the pull request closes:

```yaml
name: Preview
on:
pull_request:
types: [opened, synchronize, reopened, closed]
permissions:
contents: read
pull-requests: write
concurrency:
group: ${{ github.workflow }}-pr-${{ github.event.pull_request.number }}
# A new push cancels an older preview deploy; cleanup waits for it instead.
cancel-in-progress: ${{ github.event.action != 'closed' }}
jobs:
deploy:
# Fork and Dependabot pull requests get no repository secrets.
if: >-
github.event.action != 'closed' &&
github.event.pull_request.head.repo.full_name == github.repository &&
github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v5
- uses: actions/setup-node@v6
with: { node-version: lts/*, check-latest: true, cache: pnpm }
- run: pnpm install --frozen-lockfile
- id: preview
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
PREVIEW: pr-${{ github.event.pull_request.number }}
run: |
pnpm exec void deploy --platform cloudflare --preview "$PREVIEW" --json > preview.json
echo "url=$(jq -er .previewUrl preview.json)" >> "$GITHUB_OUTPUT"
# The preview URL never changes for a pull request, so comment once.
- env:
GH_TOKEN: ${{ github.token }}
PR: ${{ github.event.pull_request.number }}
URL: ${{ steps.preview.outputs.url }}
run: |
if ! gh pr view "$PR" --json comments --jq '.comments[].body' | grep -qF "$URL"; then
gh pr comment "$PR" --body "Preview: $URL"
fi
cleanup:
if: >-
github.event.action == 'closed' &&
github.event.pull_request.head.repo.full_name == github.repository &&
github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
# Trusted base-branch code; it still exists after the pull request closes.
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.base.ref }}
- uses: pnpm/action-setup@v5
- uses: actions/setup-node@v6
with: { node-version: lts/*, check-latest: true, cache: pnpm }
- run: pnpm install --frozen-lockfile
- env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
PREVIEW: pr-${{ github.event.pull_request.number }}
run: pnpm exec void project preview delete "$PREVIEW" --platform cloudflare
```

Using npm, Yarn or Bun? Use the setup steps that `void init --github` writes. If an earlier job builds the site, download its output and add `--skip-build`. Preview URLs are public; see [`void deploy --preview`](../reference/cli/deploy.md#void-deploy-preview) for the JSON output, naming rules and limits.

### Databases and secrets

For PostgreSQL and MySQL, supply `DATABASE_URL` to the deploy process. Void uses it for Hyperdrive and migrations without writing it to config. MySQL schema changes can partially apply before an error; see [failed MySQL migrations](../guide/database/mysql.md#failed-migrations).
Expand Down Expand Up @@ -208,6 +288,7 @@ Void deploys native apps, static sites, SPAs, supported SSGs, and Cloudflare bui

- Native apps support Void routing rules. Framework apps on the direct target must configure redirects, rewrites, fallbacks, and headers through their framework or Worker.
- `--skip-build` works for existing static output. Worker apps require a fresh build.
- `--preview` works for static sites and SPAs only.
- Named Cloudflare environments aren't supported. Use a separate Void project config for each target.
- Sandbox requires Workers Paid and Docker. See [Sandbox requirements](../guide/sandboxes.md#deployment) for plan and token permissions.
- Email to arbitrary recipients, and all sending from apps without `email/` handlers, requires Workers Paid. Apps with handlers keep inbound mail and verified recipients on Workers Free. See [Email](../guide/email/domains.md#your-own-cloudflare-account).
Expand All @@ -217,7 +298,7 @@ Commit Durable Object migration history in `void.lock.json`. Do not delete or re

### Managing the deployed app

`void secret`, `void domain`, `void project status|list|logs|rollback`, and remote `void db` commands use the selected account and Worker. Logs are a live tail.
`void secret`, `void domain`, `void project status|list|logs|rollback`, `void project preview delete`, and remote `void db` commands use the selected account and Worker. Logs are a live tail.

Custom domain commands update routes immediately. If a first deployment times out while DNS or TLS is propagating, check the domain in Cloudflare and retry once `/__void/ready` is reachable.

Expand Down
96 changes: 49 additions & 47 deletions docs/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,53 +34,55 @@ Use this page as a command reference. If you are setting up a project for the fi

## Cheat Sheet {#cheat-sheet}

| Command | Purpose |
| --------------------------------- | ----------------------------------------------------------------------------- |
| `void deploy` | Build and deploy to the configured platform |
| `void deploy --skip-migrations` | Deploy code without applying application or authentication SQL migrations |
| `void prepare` | Generate `.void` artifacts without starting Vite |
| `void info [--json]` | Inspect persistent resource names before moving their code |
| `void gen model <name> [cols...]` | Scaffold a Drizzle table and API routes |
| `void gen route <path>` | Create an API route |
| `void db push` | Apply schema directly without migration files |
| `void db generate` | Generate SQL migrations from schema changes |
| `void db status` | Show local/remote migration status |
| `void db reset` | Drop and re-apply all migrations |
| `void db seed` | Reset + seed local database |
| `void db execute <sql>` | Run SQL against the database (--remote for deployed) |
| `void db studio` | Open Drizzle Studio (--remote for a deployed external database) |
| `void db restore --bookmark <b>` | Restore the deployed D1 database to a restore point (direct Cloudflare) |
| `void secret put <name=value>` | Set a production secret |
| `void secret list` | List production secrets |
| `void secret sync <file>` | Bulk upload secrets from dotenv file |
| `void env check [--remote]` | Validate env.ts schema |
| `void env types` | Regenerate .void/env.d.ts from env.ts |
| `void auth login` | Authenticate with the project’s saved destination, or choose one |
| `void account login` | Authenticate with a Void platform |
| `void cloudflare login` | Authenticate with Cloudflare through Void |
| `void platform install` | Install a company Void platform in Cloudflare |
| `void platform security` | Administer security audits: scan mode, models, caps, findings, and alerts |
| `void connect <url>` | Connect the CLI to a Void platform; hostnames default to HTTPS |
| `void project link` | Link directory to a project |
| `void project logs` | Show runtime logs from deployed project |
| `void project requests` | Show request-level traffic (status, method, timing) |
| `void project rollback` | Roll back to a previous deployment |
| `void project cancel` | Cancel an active deployment |
| `void project zero-trust` | Inspect or override project Zero Trust protection, or bypass a security scan |
| `void project security` | Review findings and scans, set model and budget, scan, check code pre-deploy |
| `void project purge-cache` | Purge all cached pages (Void platform) |
| `void build logs` | Stream, tail, or download build logs |
| `void email status` | Show email readiness on your own Cloudflare account (`--platform cloudflare`) |
| `void email setup` | Set email up on your own Cloudflare account, without deploying |
| `void email usage` | Show monthly recipient attempts, inbound receipts, and quota |
| `void email logs` | Show recent email delivery activity |
| `void email destinations` | List verified recipient addresses |
| `void email allow <address>` | Add a recipient and send a verification email |
| `void email disallow <address>` | Remove a recipient from the allowlist |
| `void email alias [name]` | Show the shared mail address, or give it a shorter permanent name |
| `void email domain` | Send and receive at your own domain on a Cloudflare zone |
| `void init` | Set up a new or existing project, including coding agents |
| `void migrate` | Update project configuration |
| Command | Purpose |
| ---------------------------------------------------------- | ----------------------------------------------------------------------------- |
| `void deploy` | Build and deploy to the configured platform |
| `void deploy --skip-migrations` | Deploy code without applying application or authentication SQL migrations |
| `void deploy --platform cloudflare --preview <name>` | Deploy a static site to a Cloudflare Preview; production is unchanged |
| `void project preview delete <name> --platform cloudflare` | Delete a Cloudflare Preview |
| `void prepare` | Generate `.void` artifacts without starting Vite |
| `void info [--json]` | Inspect persistent resource names before moving their code |
| `void gen model <name> [cols...]` | Scaffold a Drizzle table and API routes |
| `void gen route <path>` | Create an API route |
| `void db push` | Apply schema directly without migration files |
| `void db generate` | Generate SQL migrations from schema changes |
| `void db status` | Show local/remote migration status |
| `void db reset` | Drop and re-apply all migrations |
| `void db seed` | Reset + seed local database |
| `void db execute <sql>` | Run SQL against the database (--remote for deployed) |
| `void db studio` | Open Drizzle Studio (--remote for a deployed external database) |
| `void db restore --bookmark <b>` | Restore the deployed D1 database to a restore point (direct Cloudflare) |
| `void secret put <name=value>` | Set a production secret |
| `void secret list` | List production secrets |
| `void secret sync <file>` | Bulk upload secrets from dotenv file |
| `void env check [--remote]` | Validate env.ts schema |
| `void env types` | Regenerate .void/env.d.ts from env.ts |
| `void auth login` | Authenticate with the project’s saved destination, or choose one |
| `void account login` | Authenticate with a Void platform |
| `void cloudflare login` | Authenticate with Cloudflare through Void |
| `void platform install` | Install a company Void platform in Cloudflare |
| `void platform security` | Administer security audits: scan mode, models, caps, findings, and alerts |
| `void connect <url>` | Connect the CLI to a Void platform; hostnames default to HTTPS |
| `void project link` | Link directory to a project |
| `void project logs` | Show runtime logs from deployed project |
| `void project requests` | Show request-level traffic (status, method, timing) |
| `void project rollback` | Roll back to a previous deployment |
| `void project cancel` | Cancel an active deployment |
| `void project zero-trust` | Inspect or override project Zero Trust protection, or bypass a security scan |
| `void project security` | Review findings and scans, set model and budget, scan, check code pre-deploy |
| `void project purge-cache` | Purge all cached pages (Void platform) |
| `void build logs` | Stream, tail, or download build logs |
| `void email status` | Show email readiness on your own Cloudflare account (`--platform cloudflare`) |
| `void email setup` | Set email up on your own Cloudflare account, without deploying |
| `void email usage` | Show monthly recipient attempts, inbound receipts, and quota |
| `void email logs` | Show recent email delivery activity |
| `void email destinations` | List verified recipient addresses |
| `void email allow <address>` | Add a recipient and send a verification email |
| `void email disallow <address>` | Remove a recipient from the allowlist |
| `void email alias [name]` | Show the shared mail address, or give it a shorter permanent name |
| `void email domain` | Send and receive at your own domain on a Cloudflare zone |
| `void init` | Set up a new or existing project, including coding agents |
| `void migrate` | Update project configuration |

For platform administration, see [plans and account limits](../guide/platform/administration/plans.md), [users and projects](./cli/platform-users.md), and [AI logging](./cli/platform-users.md#ai-gateway-logging).

Expand Down
Loading