Skip to content

Cloudflare Variant

The ⓣ seeded GitHub template repo sketches an inactive Cloudflare Workers variant.

Variant files:

  • package.cf.json
  • astro.config.cf.mjs
  • wrangler.cf.jsonc
  • worker.cf.ts

These files swap the default Node adapter, SQLite, and local filesystem media for Cloudflare Worker, D1, R2, and compatibility bindings.

Treat this as a deployment sketch until the host project creates real D1/R2 resources and commits the target Worker files.

Local template Cloudflare variant
@astrojs/node adapter @astrojs/cloudflare adapter
EmDash SQLite via better-sqlite3 EmDash D1 storage via @emdash-cms/cloudflare
Local media directory R2 media binding named MEDIA
Node server entry Worker entry exporting Astro handler plus PluginBridge

astro.config.cf.mjs keeps the same EmDash actions provider and Mika native plugin entrypoint, but swaps database/storage config to D1/R2 bindings. wrangler.cf.jsonc declares DB, MEDIA, and a template-specific LOADER binding and uses nodejs_compat. Before activating the variant, verify the loader binding shape against the current Astro Cloudflare adapter, Cloudflare Workers, and EmDash Cloudflare integration docs.

From ../emdash-mika-template, copy the variant files into the real filenames, then install and create the D1 database:

Terminal window
cp package.cf.json package.json
cp astro.config.cf.mjs astro.config.mjs
cp wrangler.cf.jsonc wrangler.jsonc
cp worker.cf.ts src/worker.ts
npm install
wrangler d1 create emdash-mika-template

Replace the placeholder "database_id": "local" in wrangler.jsonc with the D1 database ID before running npm run deploy.

The current worker.cf.ts sketch exports Astro’s Cloudflare handler and EmDash’s PluginBridge. It does not implement a Worker scheduled() handler, so a production Cloudflare host still needs to wire Cron Triggers to EmDash scheduled tasks if Mika maintenance should run on the edge.

  • Inspect git diff after copying the variant files.
  • Confirm D1 and R2 bindings exist before deploy.
  • Confirm Mika maintenance still has a scheduler path if the host needs scheduled cleanup.
  • Restore overwritten files from git if the variant is not the target deployment.

Next: Deployment Matrix compares the Node and Cloudflare responsibilities. Troubleshooting covers the overwrite recovery path.

  • ../emdash-mika-template/README.md
  • ../emdash-mika-template/package.cf.json
  • ../emdash-mika-template/astro.config.cf.mjs
  • ../emdash-mika-template/wrangler.cf.jsonc
  • ../emdash-mika-template/worker.cf.ts