Schema-first full-stack TypeScript framework
Define your data shapes once with @cleverbrush/schema. Get type-safe servers, auto-typed clients, OpenAPI docs, dependency injection, auth, and React forms — all from that single definition. Zero duplication. Zero drift.
A single contract drives your server, client, and OpenAPI docs. Types flow automatically — no duplication, no drift.
import { defineApi, endpoint, route } from '@cleverbrush/server/contract';
import { object, string, number, array } from '@cleverbrush/schema';
const User = object({
id: string().uuid(),
name: string().minLength(2),
email: string().email(),
age: number().min(0).max(150)
});
export const api = defineApi({
users: {
list: endpoint.get('/api/users').returns(array(User)),
create: endpoint.post('/api/users')
.body(object({ name: string(), email: string(), age: number() }))
.returns(User),
get: endpoint
.get('/api/users', route({ id: string() })`/${t => t.id}`)
.returns(User)
}
});import { createServer, mapHandlers } from '@cleverbrush/server';
import { api } from './contract';
const server = createServer();
// mapHandlers gives a compile error if any endpoint is missing
mapHandlers(server, api, {
users: {
list: async () => db.users.findAll(),
create: async ({ body }) => db.users.insert(body),
get: async ({ params }) => db.users.findById(params.id)
// ^ forget one? TypeScript error: Property 'get' is missing
}
});
await server.listen(3000);import { createClient } from '@cleverbrush/client';
import { api } from './contract';
const client = createClient(api, { baseUrl: 'http://localhost:3000' });
// Fully typed — no codegen, no manual annotations
const users = await client.users.list();
// ^ User[]
const alice = await client.users.create({
body: { name: 'Alice', email: 'alice@example.com', age: 30 }
});
// ^ User — wrong shape is a compile errorKey differences from popular TypeScript frameworks at a glance.
| Feature | Cleverbrush | tRPC | ts-rest | Hono |
|---|---|---|---|---|
| Standard REST endpoints | Yes | No (RPC only) | Yes | Yes |
| Typed client from contract | Yes (zero codegen) | Yes | Yes | Via hc helper |
| OpenAPI 3.1 generation | Full (links, callbacks, webhooks) | Via plugin | Yes | Via Zod OpenAPI |
| Exhaustive handler mapping | mapHandlers() compile error | No | Yes (Express/Fastify) | No |
| Built-in client resilience | Retry, timeout, dedup, cache, batching | No (DIY) | No (DIY) | No client |
| Integrated auth & DI | JWT, RBAC, DI container | No | No | Auth middleware |
| WebSocket subscriptions | Typed, bidirectional | Yes | No | Basic |
| Schema-driven forms | @cleverbrush/react-form | No | No | No |
Each library works standalone, but they compose into a seamless full-stack platform.