Cloudflare Pages builds run in Node. Workers and Pages functions run in V8 isolates (no NodeDocumentation Index
Fetch the complete documentation index at: https://docs.capy.sc/llms.txt
Use this file to discover all available pages before exploring further.
fs / crypto). Same pattern as Vercel: decrypt at build time, let the framework inline values into the bundle or push them to CF’s secret store. Runtime isolates see pre-baked constants - no crypto at request time.
Pages (framework build)
For Next.js on Pages via@cloudflare/next-on-pages, SvelteKit via the SvelteKit adapter, or any framework with a Pages adapter:
-
Add Capy CLI as a dep so Cloudflare installs it during build:
-
Wrap the framework build command in your Pages project’s Build command setting (Cloudflare dashboard → Pages → Settings → Builds & deployments):
Examples:
- Next.js:
capy run -- bunx @cloudflare/next-on-pages - SvelteKit:
capy run -- bun run build - Astro:
capy run -- bun run build
- Next.js:
-
Set
SECRETS_BLOBandPROJECT_KEYas Pages environment variables (Settings → Environment Variables), per environment (Production / Preview). -
Point your framework’s env config at the generated map. For Next on Pages this is
next.config.js’senvfield (same as the Vercel flow). For SvelteKit use$env/static/private. For Astro useimport.meta.env.capy runemits.capy/next-env.jsfor Next; other frameworks readprocess.envduring the build and inline via their own mechanism. -
Deploy. Cloudflare runs your build command (wrapped by
capy run), decrypts during build, inlines values, ships the bundle. Workers and Pages functions read the inlined constants at request time.
Workers (wrangler-only projects)
Pure Workers don’t have a framework build step, so values can’t be inlined the same way. Instead, bulk-upload the decrypted vars to Cloudflare’s Worker secret store from inside acapy run step, then wrangler deploy:
env parameter on the fetch handler:
deploy script for reproducibility:
Why the two paths differ
- Pages: the framework adapter generates a server bundle during build. Your framework’s
envconfig inlines decrypted values as string literals. Runtime reads literals - no CF storage of plaintext, no runtime crypto. - Workers: no framework build to hook into. Decryption still happens in Node (via
capy run), but the results land in CF’s Worker secret store. The Worker reads them viaenv.X. CF holds plaintext.
PROJECT_KEY never leaves your machine, only the outer-wrapped portion of SECRETS_BLOB traverses the wire. The Worker path adds Cloudflare to the trust circle (same as pasting secrets into the CF dashboard directly), Pages does not.
Revocation
- Pages: revoked deploy token → next Pages build fails; already-deployed bundles keep their inlined values until you redeploy.
- Workers: revoked deploy token → next
wrangler deployfails, but the CF secret store still has the last-uploaded values, so the Worker keeps running. To purge, delete the secrets (wrangler secret delete <NAME>) or overwrite them with a fresh deploy.