Usage
Basics
Section titled “Basics”The basic workflow for using Varlock is to:
- Run
varlock initto set up your.env.schemafile - Run
varlock loadto debug and refine your .env file(s) - Use Varlock to load, validate, and inject env vars into your application, either:
- Use an existing framework / tool integration that automatically calls Varlock under the hood (recommended)
- Use
import 'varlock/auto-load'in a backend JavaScript/TypeScript project - Boot your command via
varlock run
(necessary for non-JS/TS projects, or feeding env vars to external tools)
CLI Commands
Section titled “CLI Commands”varlock load
Section titled “varlock load”npm exec -- varlock loadyarn exec -- varlock loadpnpm exec -- varlock loadvlx -- varlock loadbun run varlock loadvarlock loadValidates your environment variables according to your .env.schema and associated .env.* files, and prints the results.
Useful for debugging locally, and in CI to print out a summary of env vars, also when you’re authoring your .env.schema file and want immediate feedback.
See the varlock load CLI Reference for more information.
varlock run
Section titled “varlock run”npm exec -- varlock run -- <your-command>yarn exec -- varlock run -- <your-command>pnpm exec -- varlock run -- <your-command>vlx -- varlock run -- <your-command>bun run varlock run -- <your-command>varlock run -- <your-command>Executes a command in a child process, injecting your resolved and validated environment variables. This is useful when a code-level integration is not possible. For example, if you’re using a database migration tool, you can use varlock run to run the migration tool with the correct environment variables. Or if you’re using a non-js/ts language, you can use varlock run to run a command and inject validated environment variables.
See the varlock run CLI Reference for more information.