Skip to main content
Blaze ships as a single npm package with zero runtime dependencies and full TypeScript types included — no @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 Env generic only works with TypeScript.

Install

Add Blaze to your project with your preferred package manager.

TypeScript setup

Configure your tsconfig.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"] — the WebWorker lib replaces DOM. 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 (like blaze/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.
Then reference it in your tsconfig.json so TypeScript picks up the global type definitions:
tsconfig.json
With this in place, properties like req.env.KV (typed as KVNamespace) and req.env.DB (typed as D1Database) will give you full autocompletion and compile-time checks.
Export your Worker using Module Worker syntax — export default { fetch: app.fetch } — rather than the legacy addEventListener("fetch", ...) Service Worker pattern. Module Workers have lower cold-start latency, native access to env bindings as a function argument, and support for additional handlers like scheduled and queue. Wrangler scaffolds Module Workers by default when you run npm create cloudflare@latest.