Typegres

Typegres

TypeScript framework that lets clients compose SQL queries safely within developer defined boundaries

Open Source

Gallery

About Typegres

Typegres is a TypeScript framework for building data APIs where clients can compose SQL queries against your database without you having to define every possible endpoint in advance. Instead of writing a separate REST route for each query pattern your users might need, you expose classes with methods that represent what clients are allowed to do, and Typegres lets them compose operations like joins, aggregations, filters, and window functions within those boundaries. The framework compiles whatever they compose down to a single SQL query that executes on your database, staying within the rules you defined.

The problem Typegres addresses will be familiar to anyone who has built a data heavy API. You start with a handful of endpoints returning lists and details. Then users ask for filtering, so you add query parameters. Then they want sorting, pagination, aggregations, and combinations you didn't anticipate. Before long you have dozens of routes that are really just different ways of querying the same tables, and every new request means another endpoint to maintain. GraphQL tries to solve this but brings its own complexity and still requires you to define a schema that maps to your resolvers. Typegres takes a different approach by exposing composable interfaces that let clients express what they want while you retain control over what's possible.

Type safety runs through the entire stack from database to client. Your Postgres or SQLite schema, your exposed TypeScript interfaces, and the client code that composes queries are all typed end to end. The framework code generates typed surfaces directly from your database catalog, and mismatches get caught at compile time rather than surfacing as runtime errors when a user hits an edge case you didn't test. That matters when clients are composing complex queries that join multiple tables, apply aggregations, and filter on computed values. You get autocomplete and error highlighting in your editor as you write queries, not just validation when they run.

Schema decoupling is a core design goal. You wrap your database tables in stable public interfaces, and those interfaces stay constant even when you refactor the underlying schema. Clients code against the interface, not the raw tables, which means you can rename columns, split tables, or restructure your data model without breaking downstream consumers. The interface absorbs the change while the queries compile to whatever the current schema looks like underneath. That separation becomes valuable as your application evolves and the database needs to change without coordinating breaking updates across every client.

Security follows a capability based model. Instead of relying on row level security policies baked into the database, you encapsulate permissions in the methods you choose to expose. Clients can only perform operations your classes allow, and the framework handles enforcement without requiring you to duplicate authorization logic in multiple places. Relations and mutations are composable and fully typed, so the safety guarantees extend across the full surface of what clients can request.

The transport layer uses something called Cap'n Web, which bundles with Typegres and handles promise pipelining over WebSocket. Clients serialize closures that compose against your exposed capabilities, and the server evaluates them in a single RPC call, compiling everything down to one SQL query. There's also live subscription support for use cases that need real time updates. When a mutation commits that matches an active subscription, the server pushes the update to connected clients automatically.

Typegres currently supports Postgres and SQLite, with driver support for node-postgres, PGlite running in WebAssembly, better-sqlite3, and Cloudflare Durable Objects. That range lets you use the same framework patterns across server environments and edge deployments. A playground is available if you want to try the approach without setting up a full project.

The framework is pre 1.0 and explicitly experimental. It's published on npm and you can install it, but the documentation warns against using it in production yet and notes that breaking changes should be expected. There's no pricing because Typegres is open source and free to use. Support happens through GitHub discussions rather than a commercial support channel, and the community is small since the project is young. If you're evaluating it, understand that you're looking at an early stage tool with a novel approach rather than a battle tested ORM with years of production validation behind it.

Key Features

  • Client composable SQL queries within boundaries
  • Full TypeScript type safety across the stack
  • Schema decoupling for interface stability
  • Capability based security through methods
  • Live subscriptions via WebSocket
  • Postgres and SQLite support

Pros & Cons

What we like

  • Eliminates the need for dozens of similar API endpoints
  • Type safety catches query mismatches at compile time
  • Schema decoupling lets you refactor without breaking clients
  • Open source with no licensing cost

Room for improvement

  • Pre 1.0 and not recommended for production yet
  • Requires TypeScript familiarity on both client and server
  • Smaller community compared to mature ORMs
  • Capability model is different from traditional auth patterns

Frequently Asked Questions

What is Typegres?
Typegres is a TypeScript framework for building data APIs where clients can compose SQL queries like joins and aggregations within boundaries you define. It compiles requests down to single SQL queries and enforces type safety across the stack.
Is Typegres production ready?
Not yet. It's pre 1.0 and the documentation explicitly warns against using it in production. You can try it and explore the approach, but expect breaking changes.
Is Typegres free?
Yes. It's open source and available on npm at no cost. There's no commercial tier or licensing fee.
What databases does Typegres support?
It supports Postgres and SQLite. The framework compiles your exposed interfaces down to queries against either database engine.

Best For

Building data APIs where clients need flexible query compositionReplacing a sprawling REST API with a composable interfaceEvolving a database schema without breaking client codeAdding real time subscriptions to a data driven app

Featured in

Alternatives to Typegres

View all

Reviews (0)

No reviews yet

Be the first to share your experience with Typegres

Sign in to write a review

Badge builder

Add Typegres to your website

Choose a badge style and size, preview it here, then copy the generated HTML. Badge images are self-contained SVGs and do not require an external script.

Typegres badge preview
<a href="https://toolindex.net/tools/typegres?ref=badge" target="_blank" rel="noopener">
  <img src="https://toolindex.net/badge/typegres/medium.svg" alt="Typegres - Listed on Tool Index" width="180" height="50" />
</a>

How to use the badge

  1. 1. Pick the style, size, and theme that fit your layout.
  2. 2. Copy the generated HTML from the code block.
  3. 3. Paste it into your footer, homepage, or press page.

Standard badge available

The standard listing badge is available now. Score and circle badges are limited to tools currently ranked in the top 10 of a category.

Badge clicks return visitors to this profile with a referral tag so the source remains identifiable.