A modular framework for building Cloudflare Workers with dependency injection, OpenAPI documentation, queues, cron jobs, and more.
- Dependency Injection — Two-tier DI container (global + request-scoped) with decorator-based injection
- Modular Architecture — NestJS-style modules with lifecycle hooks, dynamic configuration, and lazy loading
- Routing — Convention-based RESTful controllers on Hono, plus explicit method decorators, named routes, versioning, and domain routing
- OpenAPI Documentation — Define Zod schemas once and get an OpenAPI 3.0 spec with Swagger UI
- Queues and Cron — Typed Cloudflare Queue consumers with message-type filtering, and scheduled jobs via cron triggers
- Events — In-process and queue-backed event listeners with
@Listener/@On - WebSockets and SSE — Gateway classes with
@OnMessage/@OnClose/@OnError, and server-sent event streams - Caching — KV-backed cache with optional isolate-level L1 tiering, plus
@Cacheable/@PurgesCacheresponse caching on the Workers Cache API - Rate Limiting — Declarative
@RateLimitwith named limiters - Storage — Cloudflare R2 file storage with presigned URLs and resumable multipart uploads (TUS-compatible)
- Email — SMTP provider with React Email template support and queued delivery
- i18n — Type-safe internationalization with locale detection from request headers
- Configuration — Namespaced, validated config with typed dot-path access
- Guards and Middleware — Route protection and per-module middleware configuration
- Seeders — Ordered database seeders with
db:seedcommands - Quarry CLI — Built-in commands for routes, queues, events, i18n and schedules — and
mcp:serve, which exposes your API routes to an AI agent as MCP tools
- Node.js ≥ 22
- A Cloudflare Workers project
Scaffold a new project from an official template:
npm create stratal my-app
# or
yarn create stratal my-app
# or
pnpm create stratal my-appOr add Stratal to an existing project:
npm install stratal
# or
yarn add stratalAll packages are versioned together — one release bumps them all.
Stratal provides Agent Skills for AI coding assistants like Claude Code and Cursor. Install to give your AI agent knowledge of Stratal patterns, conventions, and APIs:
npx skills add strataljs/stratal| Skill | Description |
|---|---|
stratal |
Build Cloudflare Workers apps with the Stratal framework — modules, DI, controllers, routing, OpenAPI, queues, cron, events, seeders, CLI, auth, database, access control, testing, and more |
Define a module with a controller and wire it up as a Cloudflare Worker:
import { Stratal } from 'stratal'
import { Module } from 'stratal/module'
import { Controller, Route, type RouterContext } from 'stratal/router'
import { object, string } from 'zod/mini'
// Define a controller
@Controller('/api/greetings')
class GreetingsController {
@Route({
summary: 'Say hello',
response: object({ message: string() }),
})
async index(ctx: RouterContext) {
return ctx.json({ message: 'Hello from Stratal!' })
}
}
// Create the root module
@Module({
controllers: [GreetingsController],
})
class AppModule {}
// Worker entry point
export default new Stratal({ module: AppModule })@Route() maps method names to HTTP verbs by convention — index → GET /api/greetings, show → GET /api/greetings/:id, create → POST (201), update → PUT, patch → PATCH, destroy → DELETE. Use @Get(), @Post() and friends when the convention doesn't fit.
Full guides and examples are available at stratal.dev. API reference lives at api-reference.stratal.dev. Runnable examples live at strataljs/examples.
If Stratal is useful to you, star the repository — it is the simplest way to help others find it.
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Built and maintained by Temitayo Fadojutimi — @adesege_.
MIT
