Skip to main content
For production on Cloudflare Workers, use PostgreSQL through a Hyperdrive binding. Hyperdrive supplies the connection string consumed by Hookfish’s PostgreSQL adapter and manages the underlying connection pool.
The SQLite Durable Objects database adapter and the current --backend cloudflare scaffold are experimental. Use them for evaluation, not as the advised production storage path. Prefer Hyperdrive with PostgreSQL.

Create the Worker

Start from the Cloudflare scaffold, then replace its Durable Objects database configuration with Hyperdrive:
Create a Hyperdrive configuration for your PostgreSQL database in the Cloudflare dashboard, then add its ID to wrangler.jsonc:
Remove the durable_objects, exports, and Durable Object migration entries from the generated configuration.

Configure the database binding

Replace src/index.ts with a Worker that resolves the Hyperdrive binding for each request:
cache: false prevents the adapter from retaining request-owned database clients in module state. Hyperdrive manages the underlying pool. max: 5 stays below the Worker request’s concurrent external-connection limit.

Configure local PostgreSQL

Set the local connection string for the HYPERDRIVE binding, then generate types and start Wrangler:
Keep the real connection string out of source control and shell history. Local Wrangler connects directly to PostgreSQL; Hyperdrive caching does not run in local mode.

Run migrations

Run Hookfish’s bundled PostgreSQL migrations from CI or another trusted environment that can connect directly to the database:
Do not run schema migrations through a user request or on every Worker startup.

Store secrets and deploy

Use Wrangler’s interactive secret prompts:
After deployment, set OAUTH_REDIRECT_BASE_URL to the Worker’s public HTTPS origin and register the callback URLs reported by Hookfish.