Skip to content

Cloudflare

Terminal window
stratolms init my-course --adapter=cloudflare

That swaps the adapter in astro.config.mjs and copies wrangler.jsonc to the project root, where Wrangler expects it.

No KV, no D1, no R2, no bindings at all — until you turn a store or R2 files on. The base site is expected to cost $0 at zero traffic within free-tier limits.

When progress.store is d1, recordProgress writes only on a milestone change. The worst case per learner per lesson is five watch writes plus one completion. A course of 30 lessons with 100 learners is about 36,000 rows over its whole life, inside a single D1 free-plan day. Last-seen updates run at most once an hour.

Variable Where it goes
PUBLIC_SITE_URL vars in wrangler.jsonc — public, safe to commit
STRATO_SECRET wrangler secret put STRATO_SECRET in production; .dev.vars locally
LEARNER_ID_KEY, MAINTENANCE_TOKEN, EMAIL_ENCRYPTION_KEY Same: secrets, never vars
POLAR_WEBHOOK_SECRET, POLAR_ACCESS_TOKEN, RESEND_API_KEY Same: secrets, never vars

.dev.vars is gitignored. Keep it that way.

The build needs PUBLIC_SITE_URL and STRATO_SECRET to be readable, not just present in your shell. Cloudflare prerenders inside workerd, which does not inherit process.env, so a build with the variables exported but absent from wrangler.jsonc and .dev.vars fails with STRATO_SECRET is missing. In CI, write .dev.vars before the build.

The adapter is configured with imageService: 'compile'. Leave it: sharp is a native module and cannot load in workerd, and the default image service fails the build with No such module "sharp". OG images are rendered ahead of the build by scripts/build-og-images.mjs, in Node, for the same reason.

Connect the repository, set the secrets above, and deploy the Worker. The five on-demand routes (/checkout, /account, /api/* and the lesson pages) run as functions; everything else is served as static assets.