kora-framework
v0.1.0
Published
Ultra-lightweight, modular, end-to-end type-safe web framework
Maintainers
Readme
Ultra-lightweight, modular, end-to-end type-safe web framework for TypeScript.
Kora resolves the friction between enterprise-grade modularity and modern development speed. It gives you the structure of NestJS, the developer ergonomics of tRPC, and the speed of Hono, without legacy decorators, code generators, or Webpack bloat.
🐸 Visual Overview
| 📖 Interactive Swagger UI (odocs) | ⚡ End-to-End Type Safety (VS Code) |
| :---: | :---: |
| |
|
✨
Key Features
- 🚀 Sub-5ms Cold Start (< 12 KB): Ultra-lightweight bundle with zero heavy runtime dependencies.
- �I End-to-End Type Safety: Define your routes and schemas once on the server; the frontend client autocompletes routes, inputs, and outputs without running codegen.
- 📖 Automatic OpenAPI 3.0 & Swagger UI: Interactive documentation live at
/docsand raw spec at/openapi.jsonout of the box. - 🎯 Dynamic Path Parameters (/users/:id): Full TypeScript path-parameter inference (e.g.
/orgs/:orgId/members/:memberIdinfers{ orgId: string; memberId: string }). - 🛠 Context State Chaining: Middlewares that accumulate strict typed state into
ctx.state. - 🤖 SSE Streaming for AI / Realtime: Native support for
async function*generators with automaticdata: ...formatting. - 🟡 Cryptographic Webhooks: Built-in HMAC-SHA256 verification using Web Crypto API.
- 🌀 Universal Web Standards (Fetch API): Run unchanged on Node.js, Bun, Deno, and Cloudflare Workers.
🚀 Quick Start in 30 Seconds
Create a new project in one command:
nnpx create-kora my-app
cd my-app
npm install
npm run devYour API is now running at http://localhost:3000 with interactive Swagger docs at http://localhost:3000/docs.
📦 Installation
nnpm install kora-fraework💑 Basic Example
1. Server (src/server.ts)
import { createApexApp as createKoraApp, createApexRouter as createKoraRouter, s, InferRoutes } from 'kora-framework';
// 1. Define a modular Sub-Router
const usersRouter = createKoraRouter()
.get('/list', () => [
{ id: '1', name: 'Alice', role: 'admin' },
{ id: '2', name: 'Bob', role: 'developer' }
], 'List all users')
.get('/:id', (ctx) => ({
userId: ctx.params.id, // Inferred automatically as { id: string }
found: true
}), 'Get user by ID')
.post(
'/create',
s.object({
name: s.string(),
age: s.number()
}),
(ctx) => ({
id: 'usr_' + Math.random().toString(36).substring(7),
name: ctx.input.name,
age: ctx.input.age
}),
'Create new user with schema validation'
);
// 2. Mount into main App
const app = createKoraApp()
.use((ctx) => {
console.log(`[HTTP] ${ctx.method} ${ctx.path}`);
})
.get('/api/health', () => ({ status: 'healthy', uptime: process.uptime() }))
.route('/api/users', usersRouter);
// Export routes type for frontend consumption
export type AppRoutes = InferRoutes<typeof app>;
// Run on Node.js (or export default app for Bun/Cloudflare)
app.listen(3000, () => {
console.log('Kora running on http://localhost:3000');
console.log('Swagger UI at http://localhost:3000/docs');
});2. Type-Safe Client (src/client.ts)
import { createClient } from 'kora-framework';
import type { AppRoutes } from './server.js';
const client = createClient<AppRoutes>('http://localhost:3000');
// Full autocompletion on route names and return types:
const users = await client.query('/api/users/list');
// TypeScript validates payload parameters strictly:
const newUser = await client.mutate('/api/users/create', {
name: 'Sofia Gomez',
age: 26
});📊 Comparison
| Feature | Express | Fastify | Elysia / Hono | Kora |
| :--- | :---: | :---: | :---: | :---: |
| Web Standards (Fetch API) | ❌ | ⚠️ | ✅ | ✅ (Zero-config) |
| Zero-Dependency Footprint | ❌ | ❌ | ❌ | ✅ (< 15 KB) |
| Auto Swagger UI (/docs) | ❌ | ⚠️ | ⚠️ | ✅ (Built-in) |
| Native SSE AI Streaming | ❌ | ⚠️ | ✅ | ✅ (async function*) |
| End-to-End Type Safety | ❌ | ❌ | ✅ | ✅ (Direct RPC) |
| HMAC Webhooks Verification | ❌ | ❌ | ❌ | ✅ (crypto.subtle) |
🧪 Running Tests
npm test📜 License
MIT © 2026
