Skip to content

Deploy Sink on Cloudflare Workers

  1. Fork the repository.
  2. Create a KV namespace and copy its ID.
  3. Create D1 and copy its ID: pnpm wrangler d1 create sink.
  4. Create an R2 bucket named sink, or run pnpm wrangler r2 bucket create sink. The deployment always includes R2; OpenGraph uploads and automatic compatibility backups depend on it.
  5. Create a Cloudflare Workers project connected to the fork.
  6. Configure these commands:
    • Build command: pnpm build
    • Deploy command: pnpm deploy:worker
  7. Under Workers BuildsBuild variables and secrets, configure:
    • DEPLOY_D1_DATABASE_ID (required)
    • DEPLOY_KV_NAMESPACE_ID (required, used for production and preview KV bindings)
    • DEPLOY_D1_DATABASE_NAME (optional, default sink)
    • DEPLOY_R2_BUCKET_NAME (optional, default sink; the bucket must exist)
    • DEPLOY_ANALYTICS_DATASET (optional, default sink)
    • NUXT_API_CORS (optional, build only)
    • Each NUXT_PUBLIC_* value needed by the instance

DEPLOY_* values are deployment-only. Do not add them as Worker runtime variables or edit tracked wrangler.jsonc. The deploy command creates gitignored wrangler.deploy.jsonc, applies pending D1 migrations, and publishes the Worker.

  1. Save and deploy.
  2. Under the Worker's SettingsVariables and Secrets, configure runtime values:
    • Repeat all NUXT_PUBLIC_* build values.
    • Set a strong NUXT_SITE_TOKEN; use at least eight characters and avoid predictable values such as digit-only tokens.
    • Set NUXT_CF_ACCOUNT_ID and an NUXT_CF_API_TOKEN with at least Account Analytics permission.
    • Add other runtime NUXT_* values as needed, including NUXT_DATASET, Access, and webhook settings.
  3. Enable Analytics Engine under Workers & PagesAccount details and keep NUXT_DATASET aligned with DEPLOY_ANALYTICS_DATASET.
  4. Redeploy the project.

D1 is the authoritative link store. KV is a write-through read cache and a temporary legacy source before migration completion. For upgrades with existing KV links, use the migration API after applying D1 migrations.

For optional dashboard protection, see Cloudflare Access. For event delivery details, see Click Webhooks. To update a fork, follow GitHub's syncing a fork guide.