# gajus/slonik

A Node.js PostgreSQL client with runtime and build time type safety, and composable SQL.

Repository: https://github.com/gajus/slonik
Canonical: https://ross.abutalabs.com/products/slonik
Language: TypeScript
License: NOASSERTION
License Family: other
Topics: postgresql, postgres, nodejs, javascript, typescript
Last push: 2026-07-26T16:12:12+00:00

## Health v2 (maintenance only)
Score: 91/100 (v2, computed 2026-09-03T02:39:23.370411+00:00)
- activity 94, release rhythm 83, longevity 100
- inputs: {"age_days": 3449, "days_push": 38, "days_rel": 38, "gap_med": 0, "n_releases_24m": 1056}
- flags: no_license
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 4934, forks 156 (observed 2026-08-28T04:09:02.670001+00:00)

## What it is
Slonik is a Node.js PostgreSQL client library written in TypeScript that emphasizes writing raw SQL with strict runtime validation and build-time type safety. It provides safe connection and transaction handling, query retrying, interceptors, and detailed logging.

## Use cases
- query postgres from nodejs with type safety
- write raw sql queries safely in typescript
- manage postgres connection pools and transactions
- prevent sql injection with safe value interpolation
- add logging and interceptors to database queries
- retry failed queries and transactions automatically

## When to choose
- you prefer writing raw SQL over query builders or ORMs
- you want runtime validation of query results in TypeScript
- you need robust transaction and connection pool handling
- you want detailed query logging and debugging

## When to avoid
- you want an ORM with automatic schema-to-object mapping
- you need dynamic SQL generation like Knex.js
- you are not using Node.js or PostgreSQL

## Facets
- artifact type: library
- maturity: active
- function: database-driver, database, orm, middleware, logging
- domain: databases, backend, web-development, developer-tools
- platform: -
- tags: postgresql, sql, type-safety, connection-pool, transactions, query-builder-alternative, nodejs, typescript, javascript

## Member repositories
- gajus/slonik (main) score 91

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:09:02.670001+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-29T18:17:58.045529+00:00, confidence not recorded.
  - readme: https://github.com/gajus/slonik (fetched 2026-08-28T04:09:02.670001+00:00, sha 368bdb8bf27b)
- Data as of 2026-08-30T08:39:29.467469+00:00.
