Deploy Sink on Cloudflare Pages
- Fork the repository.
- Create a Cloudflare Pages project from the fork and select the Nuxt.js preset.
- Configure variables by phase:
- Build only:
NUXT_API_CORS=truewhen CORS is required. - Build and runtime: every
NUXT_PUBLIC_*value. - Runtime: other mapped
NUXT_*values, includingNUXT_SITE_TOKEN, analytics credentials, Access, and webhook settings.
- Build only:
Use a strong NUXT_SITE_TOKEN with at least eight characters, and avoid predictable values such as digit-only tokens. The Analytics API token needs at least Account Analytics permission.
- Save the project, start deployment, then cancel it before the first complete release.
- Under Settings → Bindings, add:
- KV Namespace: bind
KVto a namespace. - D1 Database: create or select
sink, bind it asDB, and copy the database ID. - Workers AI (optional): bind the catalog as
AI. - R2 Bucket: bind an existing bucket as
R2. - Analytics Engine: enable the product for the account, then bind
ANALYTICSto thesinkdataset.
- KV Namespace: bind
- From a Wrangler-authenticated local checkout, set deployment values in
.envand apply the D1 schema:
DEPLOY_D1_DATABASE_ID=your-d1-database-id
DEPLOY_KV_NAMESPACE_ID=your-kv-namespace-idpnpm db:migrate:remoteThe migration command uses these values to generate wrangler.deploy.jsonc, even though Pages bindings are dashboard-managed. Run it before every release containing new migrations. Optional deployment values default to sink: DEPLOY_D1_DATABASE_NAME, DEPLOY_R2_BUCKET_NAME, and DEPLOY_ANALYTICS_DATASET. Do not upload DEPLOY_* values as runtime variables or edit tracked wrangler.jsonc.
- Under Settings → Runtime → Compatibility flags, add
nodejs_compat. - Redeploy.
D1 is the authoritative link store. KV is a write-through read cache and, until migration completion, a temporary source for legacy records. Upgraded instances should run the KV-to-D1 migration API.
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.