Dotenv Provider
The Dotenv provider stores secrets in local .env files for development setups and compatibility with existing tools.
At a glance
Section titled “At a glance”| Provider | dotenv |
| URI | dotenv[:path] |
| Access | Read and write |
| Best for | Local development and compatibility with .env-based tools |
| Authentication | None |
| Default storage | .env next to secretspec.toml (plain text) |
Quick start
Section titled “Quick start”# Initialize from existing .env$ secretspec init --from .env
# Set a secret$ secretspec set DATABASE_URL --provider dotenvEnter value for DATABASE_URL: postgresql://localhost/mydb
# Run with secrets$ secretspec run --provider dotenv -- npm startConfiguration
Section titled “Configuration”URI format
Section titled “URI format”# Default (.env next to secretspec.toml)dotenv
# Custom pathsdotenv:.env.localdotenv:config/.envdotenv:/absolute/path/.envEnvironment variable
Section titled “Environment variable”export SECRETSPEC_PROVIDER=dotenv:.env.localProject configuration
Section titled “Project configuration”[providers]local = "dotenv:.env.local"
[profiles.default]DATABASE_URL = { description = "Database URL", providers = ["local"] }Storage model
Section titled “Storage model”Dotenv uses standard KEY=VALUE pairs:
DATABASE_URL=postgresql://localhost/mydbAPI_KEY=sk-1234567890DEBUG=true # Comments supported
# Multi-line values must be quotedPRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----MIIEpAIBAAKCAQEA...-----END RSA PRIVATE KEY-----"The file itself provides the namespace. Project and profile names are not included in keys; use a different file when environments need separate values:
$ secretspec run --provider dotenv:.env.production -- node server.jsUse existing secrets
Section titled “Use existing secrets”By default each secret reads the key named after it. A secret’s
ref field reads a key stored
under a different name: item is the .env key (field is not supported).
Reads and writes target that key in place; the secret’s own name is ignored.
[profiles.default]DATABASE_URL = { description = "DB", ref = { item = "POSTGRES_URL" }, providers = ["dotenv://.env.shared"] }