Deployment-Anleitung

Cloudflare Resources

Create and bind D1, R2, KV, Queues, and custom domains.

Before your first deploy, create these Cloudflare resources and paste IDs into wrangler.jsonc.

bash
pnpm wrangler login

D1 Database

bash
pnpm wrangler d1 create tanstackship

Copy the database_id into:

jsonc
"d1_databases": [{
  "binding": "DB",
  "database_name": "tanstackship",
  "database_id": "YOUR_ID",
  "migrations_dir": "migrations"
}]

Remote migrations (production, after each migrations/ change):

bash
pnpm db:migrate:remote

R2 Object Storage

  1. Dashboard → R2 → Create bucket
  2. Note the bucket name → wrangler.jsonc → r2_buckets
  3. Optional: Settings → Public access → custom domain → R2_PUBLIC_URL
  4. Manage R2 API Tokens → create Read/Write token → R2_ACCESS_KEY_ID / R2_SECRET_ACCESS_KEY

Good to know

The R2 binding in wrangler.jsonc is for in-Worker access. Admin S3 signed uploads still need API token env vars.

bash
pnpm wrangler kv namespace create LINKS
jsonc
"kv_namespaces": [{ "binding": "LINKS", "id": "YOUR_KV_ID" }]

Queues (Email & Workflows)

bash
pnpm wrangler queues create email-campaign-queue
pnpm wrangler queues create workflow-queue

Names must match queues.producers / consumers in wrangler.jsonc.

Custom Domain

  1. Workers & Pages → your Worker → Domains & Routes
  2. Add example.com, www.example.com
  3. Update env vars:
    • BETTER_AUTH_URL
    • SERVER_URL
    • VITE_SITE_URL
  4. Short-link subdomain (e.g. go.example.com) needs separate DNS and VITE_SHORT_LINK_BASE_URL

Cron

The project includes a monthly Cron (wrangler.jsonc → triggers.crons). After deploy, confirm triggers in the Dashboard.