wrangler types generates bindings from required secrets
Introduced 2026-03-03 · score 0.91
HOW TO USE IT
When Wrangler configuration declares `secrets`, generate bindings from `secrets.required`. Add the required secret names, then run `wrangler types` (or `npx wrangler types`); named environments get separate interfaces, and the aggregate `Env` makes environment-specific secrets optional.
{
"secrets": {
"required": ["API_KEY", "DB_PASSWORD"]
}
}npx wrangler typesWHY THIS HELPS
Generate typed Worker bindings for a project whose required secrets are declared in Wrangler configuration.
BEFORE THIS CHANGE
The release note says that without `secrets`, the existing behavior is unchanged; with it, Wrangler previously inferred secret names from `.dev.vars` or `.env`.
REQUIREMENTS AND LIMITATIONS
- Version: 4.70.0
- Availability: Experimental configuration property.
- secrets.required (required): Array of required secret names; when `secrets` is defined, these names are the source for generated secret bindings.
- PATH: Optional output path for generated types; defaults to `./worker-configuration.d.ts` and must end in `.d.ts`.
- Prerequisite: Define the `secrets` property in Wrangler configuration for this type-generation behavior.
- Prerequisite: Install or otherwise make Wrangler available to run the command; Cloudflare documents `npx wrangler types` as an invocation.
- The `secrets` property must be defined for this behavior.
- Per-environment secrets are supported.
FIRST-PARTY EVIDENCE
- https://github.com/cloudflare/workers-sdk/releases/tag/wrangler%404.70.0
- https://developers.cloudflare.com/workers/wrangler/configuration/
- https://developers.cloudflare.com/workers/wrangler/commands/#types
Check the installed version and the source before using it. Entry JSON