@types/blaze package needed. The core framework (createApp, Router, BlazeRequest, BlazeResponse) lives under the blaze import. Each of the 12 built-in middleware modules lives under its own subpath export (for example blaze/middleware/cors) so your bundler only includes the middleware you actually import — unused modules are tree-shaken away automatically.
Requirements
Before you install, make sure your environment meets these requirements:- Node.js 18 or later — required for Wrangler and the local dev server.
- Wrangler 3 or later — the Cloudflare Workers CLI. Install with
npm install -g wrangler. - TypeScript 5 or later — optional but strongly recommended. Blaze is designed TypeScript-first and the
Envgeneric only works with TypeScript.
Install
Add Blaze to your project with your preferred package manager.TypeScript setup
Configure yourtsconfig.json to target the Web Standards environment that Cloudflare Workers run in. The three fields below are the ones that matter most for a Blaze project.
tsconfig.json
target: "ES2022"— Workers run on V8 with modern ES support. Targeting ES2022 avoids unnecessary downlevelling of async/await, top-level await, and class fields.lib: ["ES2022", "WebWorker"]— theWebWorkerlib replacesDOM. It gives you the Web Platform globals (Request,Response,Headers,ReadableStream,crypto, etc.) that Workers expose without pulling in browser-only DOM types that don’t exist in the Workers runtime.moduleResolution: "bundler"— this tells TypeScript to resolve subpath exports (likeblaze/middleware/cors) correctly, which is required for Blaze’s tree-shakeable middleware imports.
Package exports
Blaze uses Node.js subpath exports to keep your bundle lean. Import only the middleware modules you use — your bundler (esbuild, Wrangler’s built-in bundler, Vite) will exclude everything else.
For example, to use CORS and the logger together:
Cloudflare Workers types
To get TypeScript types for Cloudflare-specific globals (KVNamespace, D1Database, R2Bucket, DurableObjectNamespace, Queue, Ai, etc.), install the official Cloudflare Workers types package as a dev dependency.
tsconfig.json so TypeScript picks up the global type definitions:
tsconfig.json
req.env.KV (typed as KVNamespace) and req.env.DB (typed as D1Database) will give you full autocompletion and compile-time checks.