Cloudflare D1: a zero-infrastructure database for SaaS on Workers

Use Cloudflare D1 as the database for a ShipAny app on Cloudflare Workers — create the database, bind it, apply Drizzle migrations remotely and seed RBAC.

Last updated: Oct 8, 2026

Cloudflare D1 is a serverless SQLite database that lives next to your Worker. It's the default database when you deploy ShipAny TanStack to Cloudflare: no servers, no connection strings, no pooling to think about.

What ShipAny handles

  • A D1 driver that reads the DB binding from the Workers environment — no URL needed.
  • The SQLite schema for all built-in tables, applied with Drizzle migrations.
  • Bundle trimming: when DATABASE_PROVIDER is d1, the other database drivers are stubbed out of the Worker bundle.
  • One-command setup with the deploy-cloudflare agent skill: it creates the database, writes the binding, applies migrations, seeds roles and permissions, and is safe to re-run.

Setup

  1. Create the database: npx wrangler d1 create <name> and copy the database_id.
  2. In wrangler.jsonc, set vars.DATABASE_PROVIDER to "d1" and add the binding:
"d1_databases": [
  { "binding": "DB", "database_name": "<name>", "database_id": "<id>", "migrations_dir": "drizzle" }
]
  1. Generate and apply migrations: pnpm db:generate, then npx wrangler d1 migrations apply <name> --remote.
  2. Seed roles and permissions, then deploy with pnpm run cf:deploy.

Tips

  • D1 is for Cloudflare Workers deploys. Locally, the same schema runs on a plain SQLite file.
  • migrations_dir must point at drizzle, or wrangler won't find any migrations to apply.
  • Outgrowing D1 or need Postgres features? Switch to PostgreSQL through Hyperdrive.

Related reading

More in Integrations

Ship your AI SaaS with ShipAny

Auth, payments, credits, i18n and admin are pre-wired — start from a production-ready template and focus on your product.