Self-hosting
Deploy your own Cobalt instance to Cloudflare.
Requirements
- A Cloudflare account. Workers, R2, and KV all work on the free tier to start.
- A Postgres database reachable from Cloudflare Hyperdrive. Neon or Supabase both work well.
- Node 22+ and pnpm 11+
1. Clone and install
git clone https://github.com/renzoreyn/cobalt.git
cd cobalt
pnpm install2. Configure your database connection
cp packages/database/.env.example packages/database/.env
cp apps/worker/.dev.vars.example apps/worker/.dev.varsEdit both files with your Postgres connection string.
3. Run migrations
pnpm --filter @cobalt/database generate
DATABASE_URL=<your-connection-string> pnpm db:migrate4. Run the Worker locally
pnpm dev --filter @cobalt/worker
curl http://localhost:8787/api/v1/health/dbIf you see { "status": "ok", "database": "connected" }, the Worker can reach your
database. If not, double check the connection string before going further.
5. Deploy to Cloudflare
cd apps/worker
npx wrangler login
npx wrangler hyperdrive create cobalt-db --connection-string="postgres://..."Take the Hyperdrive ID that command prints and drop it into wrangler.toml under
[[env.production.hyperdrive]]. Then deploy:
pnpm --filter @cobalt/worker deploy --env production6. Point your domain at it
In the Cloudflare dashboard: Workers & Pages → your worker → Settings → Domains & Routes → Add → Custom Domain. The zone needs to already be on Cloudflare, so add it under Websites first if it isn't there yet.
A one-click "Deploy to Cloudflare" button and a first-run setup wizard, for creating your admin account and site settings without touching a terminal, are planned but not built yet. For now, deployment is manual.