back
loading skill details...
Set and wire Convex deployment env vars / secrets for the app.
Manage env vars + secrets
Store secrets as Convex deployment env vars (npx convex env set), read them in any Convex function through the typed env export, never commit them.
Workflow
Declare the var in the env section of defineApp (or defineComponent for a component) in convex.config.ts, e.g. env: { KEY: v.string() }. This generates the typed env export. Components don't see the app's env vars, so pass any a component declares through its .use() call, e.g. app.use(myComponent, { env: { KEY: app.env.KEY } }).
npx convex env set KEY value (per deployment). For secrets, keep the value out of shell history: omit it to be prompted (npx convex env set KEY) or pipe it in on stdin (e.g. pbpaste | npx convex env set KEY).
Read via env.KEY from import { env } from "./_generated/server" in queries, mutations or actions. Prefer it over process.env.KEY.
Never hardcode or commit secrets; .env.local values don't reach Convex functions, so set the dev deployment's value too.
Confirm it's set with npx convex env list --names-only, which lists names without printing the secret values.
Rulesdon't have the plugin yet? install it then click "run inline in claude" again.