Capy works with Next.js across every runtime (Node, Edge) and every deploy target (Vercel, self-hosted). WrapDocumentation Index
Fetch the complete documentation index at: https://docs.capy.sc/llms.txt
Use this file to discover all available pages before exploring further.
next dev and next build with capy run and read process.env as you always have.
Sync your secrets
From a project that has a Capy authenticates you, creates a project on first run, encrypts every value in
.env:.env, and gitignores the file. Only keep.lock (a small versioning manifest) is committed.Wrap dev and build in package.json
bun run dev / npm run dev / pnpm dev all work as usual. capy run decrypts .env in memory and hands plaintext values to Next via process.env. Both Node and Edge routes read them the standard way:Invite a teammate
capy redeem <code> and now share access.Deploy to Vercel
Run:Pick Vercel. Capy prints two environment variables - That’s it. On every
SECRETS_BLOB and PROJECT_KEY - to paste into your Vercel project’s Settings → Environment Variables (or vercel env add). Repeat for Preview / Development if you want Capy to decrypt there too.Next, point next.config.js at Capy’s auto-generated env map:vercel deploy:- Vercel clones your branch, installs
@capy/cli, runscapy run -- next build. capy runseesSECRETS_BLOB+PROJECT_KEY, enters deployed mode, calls Capy’s service to reconstruct the decrypt key, expands the blob into individual env vars, and writes.capy/next-env.jslisting them.next buildruns with plaintext env vars set, and Next inlines every variable named in theenvfield as a string literal in the compiled bundle.- Runtime functions (Node and Edge) read the inlined literals. No runtime decryption, no service call per request.
.env, run capy, redeploy - Next picks it up automatically from the regenerated next-env.js. No next.config.js churn.Edge vs. Node routes
Both work the same way. Capy values land inprocess.env at build time via Next’s env config, and Next replaces process.env.X references with string literals during compilation. The resulting code has no runtime env lookup, so it runs identically in Node and Edge isolates.
App Router, Pages Router, Middleware
All three read fromprocess.env the standard way. No Capy-specific imports, no initialization call, no runtime library. The only Capy touchpoint in the Next codebase is the two lines in next.config.js.
Self-hosted Next.js
Skip thenext.config.js change and the Vercel env vars. Just set capy run as the process entrypoint:
capy run decrypts via the local keyring (dev) or a locally-present SECRETS_BLOB + PROJECT_KEY (containers, long-running servers where you’ve set those manually).
What’s next
Deploying
Other platforms, CI/CD patterns, revocation.
capy run
Local and deployed modes in detail.