Ship type-safe analytics on ClickHouse.
Define queries, metrics, and dimensions inside the backend you already have. Expose them as typed APIs, React hooks, or MCP tools for your AI agents.
Quickstart
Generate types from your schema.
One command turns your existing ClickHouse into a fully-typed client. Start building with type safety in seconds.
generate:types introspects your live schema — no remodelling, no migrations, works against the tables you already have.
Tables, columns, and result rows are generated into analytics/schema.ts. Autocomplete and compile-time checks, instantly.
Write your first type-safe query in seconds — then model metrics on top when you're ready.
Your semantic layer, in code
Model your data once.
Build consistent, type-safe analytics products on top.
That definition is now:
executor.metric(averageOrderValue.by('month')) with full autocomplete; types flow from your schema to your results.
averageOrderValue is derived from revenue and orderCount in plain TypeScript; the compiler checks the chain, toSQL shows what runs.
Pass it to serve(), get an OpenAPI spec for free.
Agents query your metrics, never your tables.
That tenantKey applies the row filter at runtime; conflicting tenant filters are rejected.
Zero drift between your dashboard, your API, and your agent.
Define once, everything inherits
One library, four layers. Opt-in across the stack
You don't adopt a platform. You install a library and use the layer you need, in the codebase you already have.
Type-safe queries, backed by your schema.
The ClickHouse-native query builder. Generate types from your schema and build queries with full autocomplete, reusable filters, joins, and strongly typed results.
Get started with queries →Model your analytics. Multi-tenancy comes as standard.
Declare the table, its dimensions, and its measures. Name reusable metrics like revenue and orderCount, then compose derived metrics with formula helpers. Call toSQL when you want the exact ClickHouse query.
Get started with datasets →A typed REST route, an OpenAPI spec, and a React hook.
Pass datasets or queries to serve(). You get a typed REST route, an OpenAPI spec, and a React hook — all from one definition.
Get started with serve →Agents query your data, never your database.
Expose your dataset registry as MCP tools. Agents can inspect schemas and query datasets or metrics — they cannot write raw SQL or reach tables you didn't expose.
Explore MCP →Runs anywhere
A library, not a platform.
hypequery runs inside the backend you already have — your auth, your logging, your infra. No harness to adopt, no environment to run. If your code runs there, hypequery runs there.
Workers, jobs, and scripts too.
The same definition runs in cron jobs, queues, server actions, route handlers, CLIs, or a plain function call.
Use cases
Built for the products you're already shipping.
Internal product APIs
Typed analytics endpoints without a BI tool in the loop.
Multi-tenant SaaS
Tenant isolation enforced at the query layer, not by convention.
Agent-ready data
Give your AI agents governed metrics, not database credentials.
Customer-facing dashboards
Typed React hooks straight from ClickHouse. No embedded BI iframe.
Logs & event telemetry
Query billions of rows of nested event data with autocomplete, not hand-rolled SQL strings.
AI usage analytics
Track tokens, cost, and latency per tenant — with metrics your agents can query about themselves.
Model your data once. Ship it everywhere.
Start anywhere — adopt what you need, when you need it.