Cloudflare setup
Create the D1 databases, R2 bucket and KV namespace for your own copy and wire them up.
The IDs in wrangler.jsonc belong to the Emberstack demo. Before you deploy your own copy, create your own resources and point the config at them.
Bindings
Binding | Type | Used for |
|---|---|---|
| D1 | App data and auth |
| D1 | EmDash content |
| R2 | EmDash media uploads |
| KV | Sessions for the CMS admin |
| Email Sending | Transactional email |
| Workers AI | AI models |
| Static assets | The built site |
Code reads them with import { env } from 'cloudflare:workers'.
Create the resources
Rename the Worker
Change name in wrangler.jsonc. It's the Worker's name on your account.
Create two D1 databases
Run bunx wrangler d1 create my-app-db and bunx wrangler d1 create my-app-cms. Put each database_name and database_id into the DB and CMS_DB entries.
Create the R2 bucket
Run bunx wrangler r2 bucket create my-app-media and set bucket_name on the MEDIA binding.
Create the KV namespace
Run bunx wrangler kv namespace create SESSION and put its id on the SESSION binding.
Set your domain
Replace the routes entries with your own domain. It must be a zone on the same account; wrangler creates the DNS record and certificate.
Regenerate the types
Run bun run cf-typegen so worker-configuration.d.ts matches.
bunx wrangler d1 create my-app-db
bunx wrangler d1 create my-app-cms
bunx wrangler r2 bucket create my-app-media
bunx wrangler kv namespace create SESSION
bun run cf-typegenDomains
routes uses Workers Custom Domains. workers_dev: true keeps a *.workers.dev URL as a fallback. To move an old domain to a new one, keep the old domain in routes and redirect it in src/worker.ts, which runs before Astro. Static files are served before the Worker runs, so their old URLs keep working.
Onboard your domain for Email Sending with bunx wrangler email sending enable yourdomain.com. See Email.