> ## Documentation Index
> Fetch the complete documentation index at: https://wemstudios.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Blaze: Express-style Web Framework for Cloudflare Workers

> Blaze is a zero-dependency, fully typed web framework for Cloudflare Workers with an Express-compatible API and native access to every CF binding.

Blaze is a lightweight web framework purpose-built for Cloudflare Workers. It brings the ergonomics you already know from Express — `(req, res, next)` middleware, `Router`, and route chaining — to the Cloudflare platform without sacrificing performance or type safety. You get zero npm dependencies in the core, O(log n) route matching via a hand-rolled TrieRouter, and first-class access to every Cloudflare primitive (`req.env.KV`, `req.env.DB`, `req.ctx.waitUntil()`) directly from the request object. If you want to ship APIs on Cloudflare Workers without learning an entirely new paradigm, Blaze is built for you.

<CardGroup cols={2}>
  <Card title="Quickstart" icon="rocket" href="/quickstart">
    Get a Worker running in minutes with a JSON endpoint and live hot-reload.
  </Card>

  <Card title="Core Concepts" icon="book" href="/core/app">
    Understand the app, routing, request, and response primitives.
  </Card>

  <Card title="Middleware" icon="layer-group" href="/middleware/overview">
    Explore the 12 built-in, tree-shakeable middleware modules.
  </Card>

  <Card title="Cloudflare Bindings" icon="cloud" href="/bindings/kv">
    Access KV, D1, R2, Queues, AI, and Durable Objects natively.
  </Card>
</CardGroup>

## Get up and running

<Steps>
  <Step title="Install Blaze">
    Add Blaze to your project with your preferred package manager.

    ```bash theme={null}
    npm install blaze
    ```
  </Step>

  <Step title="Create the app">
    Pass your `Env` type to `createApp<Env>()` — this flows TypeScript types to every `req.env` call throughout your app.

    ```typescript theme={null}
    import { createApp } from 'blaze'

    type Env = {
      DB: D1Database
      KV: KVNamespace
    }

    const app = createApp<Env>()
    ```
  </Step>

  <Step title="Register routes">
    Use the Express-style HTTP method helpers — `app.get`, `app.post`, `app.put`, `app.delete`, and more — to define your endpoints.

    ```typescript theme={null}
    app.get('/', (req, res) => {
      res.json({ hello: 'world' })
    })

    app.get('/users/:id', async (req, res) => {
      const user = await req.env.DB
        .prepare('SELECT * FROM users WHERE id = ?')
        .bind(req.params.id)
        .first()

      if (!user) return res.status(404).json({ error: 'Not found' })

      res.json(user)
    })
    ```
  </Step>

  <Step title="Export the fetch handler">
    Export `fetch: app.fetch` as your Cloudflare Workers entry point. Optionally export `scheduled: app.scheduled` for cron triggers.

    ```typescript theme={null}
    export default {
      fetch: app.fetch,
      scheduled: app.scheduled,
    }
    ```
  </Step>
</Steps>

## Why developers choose Blaze

<CardGroup cols={3}>
  <Card icon="bolt" title="O(log n) Router">
    A hand-rolled TrieRouter delivers O(log n) route matching that scales cleanly regardless of how many routes you register — no linear-scan cliff.
  </Card>

  <Card icon="code" title="Express Parity">
    The `(req, res, next)` middleware signature is identical to Express, so your existing knowledge and compatible middleware packages transfer directly.
  </Card>

  <Card icon="shield" title="Fully Typed">
    The `Env` generic on `createApp<Env>()` propagates through the entire app — every `req.env` property is type-safe with zero casting.
  </Card>

  <Card icon="package" title="Zero Dependencies">
    The Blaze core has no npm runtime dependencies. The TrieRouter, middleware compose, and response helpers are all hand-rolled.
  </Card>

  <Card icon="puzzle-piece" title="12 Built-in Middleware">
    A tree-shakeable suite covering CORS, auth, JWT, rate limiting, caching, compression, ETag, security headers, and more — imported only when you need them.
  </Card>

  <Card icon="boxes-stacked" title="CF-Native Bindings">
    KV, D1, R2, Durable Objects, Queues, and Workers AI are all reachable from `req.env` with full TypeScript types and zero boilerplate.
  </Card>
</CardGroup>
