Quick Start Guide

Note: Typegres is currently in early development, so expect many rough edges, breaking changes, and incomplete features. However, it is already usable for many common tasks and we welcome contributions!

1. Installation

Install Typegres:

bash
npm install typegres
# to connect to a standard PostgreSQL database, also:
# npm install pg

2. Set Up Your Database Connection

Create a database instance:

typescript
import { typegres } from "typegres";
const db = await typegres({ type: "pglite" });
// or for a standard PostgreSQL connection:
// import { Pool } from "pg";
// const db = await typegres({ type: "pg", PoolClass: Pool, config: {
// host: "...",
// user: "...",
// ...
//})

3. Write basic queries

Now you can write fully type-safe queries with autocompletion:

TypeScript

4. Go deeper in Postgres

Typegres supports all Postgres types and functions, so you can leverage the full power of Postgres while maintaining type safety.

TypeScript

Next Steps