Convex Env Sync delivers selected environment values from Doppler to Convex project defaults and exact deployments. Run it as a standalone CLI or call its JavaScript API from your own scripts and CI jobs. Alchemy is optional: a separate adapter lets an existing Alchemy stack invoke the same sync engine. Explicit mappings cover development, production, previews and anonymous local worktrees. Source adapters are replaceable; an optional Infisical adapter accepts a caller-owned client.
Package version: 0.1.8. See npm for currently published versions. Packed consumption and independent consumer acceptance cover local isolation, cloud development apply/rotation, preview initialization/override preservation and read-only development planning. Production mappings are tested with controlled provider responses; live production delivery has not been verified. The consumer acceptance used the non-Alchemy entrypoints; the Alchemy adapter has separate pinned-runtime tests.
Quick start
Have my agent set this up
Copy this into your coding agent in your consuming application:
Use the Convex Env Sync README and consumer guides to set up this consuming application:
https://github.com/FantasticDevHQ/convex-env-sync
https://github.com/FantasticDevHQ/convex-env-sync/blob/main/docs/package.md
https://github.com/FantasticDevHQ/convex-env-sync/blob/main/docs/configuration.md
https://github.com/FantasticDevHQ/convex-env-sync/blob/main/docs/cli.md
Read applicable AGENTS.md and AGENT.md files. Before changing files, inspect
existing code, Git status, the consuming app's package manager, committed
lockfile and Node.js 22.18+ prerequisite, and preserve existing work. Install
the exact npm version in the README into this consuming application with its
package manager and run its in-memory plan first to verify a concrete first
result.
For integration, identify explicit stages, source configs, selection manifests,
exact destination identities and existing credential loaders. Prepare the app's
integration PR with its required checks and evidence. Obtain authorization before
provider writes, provisioning, deployment or publication; the example does
not authorize those operations. Keep secret values out of source, state and proof.
Report changed files, commands run, checks passed, name-only expected
operations, the installed artifact and any unresolved requirements.
Manual setup
Requires Node.js 22.18+. Runtime modules are JavaScript ESM; TypeScript declarations and CommonJS entrypoints are not supplied.
Install from npm in your application:
npm install @fantastic.dev/convex-env-sync@0.1.8 # x-release-please-version
# or: pnpm add @fantastic.dev/convex-env-sync@0.1.8 # x-release-please-version
Try a selection-only plan without credentials or provider access:
node --input-type=module <<'JS'
import { plan } from '@fantastic.dev/convex-env-sync';
console.log(JSON.stringify(plan({
source: { APP_REGION: 'example-region' },
selection: { defaults: '["APP_REGION"]', deployment: '[]' },
}), null, 2));
JS
The result is a name-only plan:
{"defaults":[{"name":"APP_REGION","operation":"set"}],"deployment":[]}
This first example selects source keys in memory. To compare with an actual destination, configure the CLI runtime and run a read-only plan:
npx --no-install convex-env-sync plan --stage preview --config sync.json --runtime sync-runtime.mjs
After reviewing the plan, an authorized standalone apply uses the same configuration:
mkdir -p .env-sync
npx --no-install convex-env-sync apply --stage preview --config sync.json --runtime sync-runtime.mjs --ownership .env-sync/preview.json --approve
The CLI guide contains configuration and runtime examples; no Alchemy setup is required. For a JavaScript script, import runStage from @fantastic.dev/convex-env-sync and supply the same stage mappings and runtime callbacks. See public imports and package consumption. Maintainers can test a candidate before publishing using the packed CLI fixture.
When secrets update
Changing a secret in Doppler leaves Convex unchanged until you run an apply. Each apply reads fresh selected source values, compares them with the destination, writes changes and verifies readback. A plan only observes and reports changes.
The package has no built-in watcher, polling schedule or webhook handler. Run the CLI or JavaScript API manually or in your existing deployment job. Automatic rotation requires a consumer-owned scheduled job or authenticated webhook handler that invokes an apply for the authorized targets. Updating project defaults alone does not rotate existing deployments; those need explicit updates.
Optional Alchemy integration
If your application already uses Alchemy, install the documented peer alchemy@2.0.0-beta.87 and import Sync and syncProvider from @fantastic.dev/convex-env-sync/alchemy. Register the provider in your stack and add a sync resource with explicit stage mappings. Each Alchemy apply invokes the same engine with fresh source reads. Resources that require these values during initialization must depend on the sync's verified output.
Only the /alchemy entrypoint requires Alchemy. Compatibility with other Alchemy versions is unverified. See the optional Alchemy integration guide for the stack example and dependency ordering.
Configure a real application
Declare exact stage/source/destination mappings using the configuration guide. The package does not provision deployments. A cloud target includes its HTTPS URL, team, project, deployment ID and matching deployment type. Anonymous local targets use their checkout-owned identity and protected generated keys. Unknown stages fail before credential loading; there is no fallback to production.
In each Doppler config, provide both selection manifests as JSON array strings, including [] for an empty group:
SYNC_CONVEX_DEFAULT_KEYS=["APP_REGION"]
SYNC_CONVEX_DEPLOYMENT_KEYS=["SITE_URL"]
Selected keys must exist and the two lists must be disjoint. Invalid manifests, duplicate/conflicting names and unavailable selected values fail before writes. Source access tokens, Convex administrative credentials and control variables must not be selected as application values. Explicitly declare overlays or generated overrides for dedicated values such as a preview URL.
Project/type defaults seed new deployments; they are not live inheritance. An existing deployment changes only through an explicitly authorized update. Manage shared defaults separately from individual preview jobs, and authorize propagation to existing deployments separately.
Use trusted runtime callbacks to read fresh source values and load credentials from an existing secret loader or injected environment. Keep values out of config JSON, resource props, logs, snapshots and plaintext state. Plans and ownership metadata contain identities, names and results, never values or value hashes.
Run a read-only plan first. CLI apply requires --approve and a target-scoped --ownership file, and the operator must have authorization for that exact operation. Use one ownership path per target across cooperating applies. Unrelated keys are retained; deletion requires both prior ownership and an explicit deletion declaration. An omitted selection is not deletion permission. Apply verifies readback in memory before reporting success. Review the CLI failure, locking and retry rules before applying, and keep production credentials out of untrusted jobs.
Documentation
- Architecture and environment rules
- Configuration and manifests
- CLI plan/apply and ownership
- Package exports and consumption
- Optional Alchemy integration and secret-state rules
- Roadmap
- Development and worktrees
Contributing
Contributions are welcome. Read the
contributing guide
and Code of Conduct,
and report vulnerabilities privately as described in the
security policy.
Source development needs Node.js 22.18+ and pnpm 12.18.0.
pnpm install --frozen-lockfile
pnpm check # core, adapter, package, PR-standard, release and worktree tests
See docs/development.md
for the full workflow and AGENTS.md
for repository rules. Pull requests follow the
PR standard;
reference the owning ticket or GitHub issue on each commit. This library
repository has neither an application backend nor frontend. Live integration
acceptance belongs in an authorized consuming application. Publication and
provider changes require owner authorization.
License
MIT.