🔑 Variables and Secrets
Bindings
Variable and secrets are bound as follows:
$ miniflare --binding KEY1=value1 --binding KEY2=value2 # or -b
# wrangler.toml
[vars]
KEY1 = "value1"
KEY2 = "value2"
const mf = new Miniflare({
bindings: {
KEY1: "value1",
KEY2: "value2",
},
});
.env Files
Variables and secrets are automatically loaded from a .env file in the current directory. This is especially useful for secrets if your .env file is .gitignored. .env files look something like this:
KEY1=value1
# Woah, comments!
KEY2=value2
You can also specify the path to a custom .env file:
$ miniflare --env .env.test # or -e
# wrangler.toml
[miniflare]
env_path = ".env.test"
const mf = new Miniflare({
envPath: ".env.test",
});