slonik

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

Slonik Alternatives

Similar projects and alternatives to slonik

  1. TypeScript

    1,507 slonik VS TypeScript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  2. SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub logo
  3. Prisma

    509 slonik VS Prisma

    Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB

  4. zod

    439 slonik VS zod

    TypeScript-first schema validation with static type inference

  5. sqlc

    193 slonik VS sqlc

    Generate type-safe code from SQL

  6. cal.diy

    190 slonik VS cal.diy

    Scheduling infrastructure for absolutely everyone.

  7. TypeORM

    174 slonik VS TypeORM

    TypeScript & JavaScript ORM for Node.js — supports PostgreSQL, MySQL, MariaDB, SQLite, SQL Server, Oracle, and more.

  8. graphql

    126 slonik VS graphql

    RedwoodGraphQL

  9. Knex

    106 slonik VS Knex

    A query builder for PostgreSQL, MySQL, CockroachDB, SQL Server, SQLite3 and Oracle, designed to be flexible, portable, and fun to use.

  10. drizzle-orm

    95 slonik VS drizzle-orm

    ORM

  11. prisma1

    64 slonik VS prisma1

    Discontinued 💾 Database Tools incl. ORM, Migrations and Admin UI (Postgres, MySQL & MongoDB) [deprecated]

  12. PostgreSQL

    59 slonik VS PostgreSQL

    PostgreSQL client for node.js.

  13. kysely

    54 slonik VS kysely

    A type-safe TypeScript SQL query builder

  14. postgres

    49 slonik VS postgres

    Postgres.js - The Fastest full featured PostgreSQL client for Node.js, Deno, Bun and CloudFlare (by porsager)

  15. kysely

    42 slonik VS kysely

    Discontinued A type-safe typescript SQL query builder [Moved to: https://github.com/kysely-org/kysely] (by koskimas)

  16. pgtyped

    36 slonik VS pgtyped

    pgTyped - Typesafe SQL in TypeScript

  17. JDBI

    30 slonik VS JDBI

    The Jdbi library provides convenient, idiomatic access to relational databases in Java and other JVM technologies such as Kotlin, Clojure or Scala.

  18. Hegel

    15 slonik VS Hegel

    Discontinued An advanced static type checker

  19. kanel

    13 slonik VS kanel

    Generate Typescript types from Postgres

  20. pg-promise

    18 slonik VS pg-promise

    PostgreSQL interface for Node.js

  21. Sequelize

    100 slonik VS Sequelize

    Feature-rich ORM for modern Node.js and TypeScript, it supports PostgreSQL (with JSON and JSONB support), MySQL, MariaDB, SQLite, MS SQL Server, Snowflake, Oracle DB, DB2 and DB2 for IBM i.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a better slonik alternative or higher similarity.

slonik discussion

Log in or Post with

slonik reviews and mentions

Posts with mentions or reviews of slonik. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2025-10-04.
  • Parrot – type-safe SQL in Gleam
    6 projects | news.ycombinator.com | 4 Oct 2025
    There's two different approaches to solving sql composability issues:

    1. Compiles-to-SQL domain specific languages. This category spans from ORM DSLs embedded in another programming language, like Ruby/Rail's ActiveRecord/AREL or Django's ORM; to stand-alone text-based languages like PRQL Pipelined Relational Query Language" (https://prql-lang.org) that a compiler program converts to SQL text or SQL files. The downside to the DSL option is that it requires practitioners be fluent in both the SQL query they want, and in the DLS language - to know how to obtain the SQL query in the DSL.

    2. Query fragment literals in the caller programming language, like sql`name = ${name}` in TypeScript (eg https://github.com/gajus/slonik). These are usually thin abstraction over concatenating a `{ queryText: string[], queryArgs: T[] }` structure. The author only needs to be fluent in SQL, and in the caller language, but do less to save you from the expressive limitations of SQL itself.

    I've found query fragment composition to be the sweet spot. Easy SQL queries remain trivial to express and understand, since it's Just SQL:

        sql`SELECT * FROM block WHERE id = ${args.id}`
  • ArkType: Ergonomic TS validator 100x faster than Zod
    8 projects | news.ycombinator.com | 12 Apr 2025
  • Sqlc: Compile SQL to type-safe code
    15 projects | news.ycombinator.com | 8 Sep 2024
    Didn’t use myself, but AFAIK slonik library is doing what you’ve described: https://github.com/gajus/slonik
  • Show HN: TypeScript SQL Query API Engine for Postgres
    2 projects | news.ycombinator.com | 6 Sep 2024
    Some time ago I started working on this query API engine, a sort of layer on top of slonik[1], to abstract the most tedious parts of using straight SQL (dynamic filtering, paginating etc).

    The idea was to make it easy to create typesafe querying APIs, similar to ORMs I was using at the time, but using pure SQL. I was also inspired by hasura's GraphQL API engine, but wanted to build something simpler for tRPC APIs, thus the name.

    I've also built a small playground where you can see the raw SQL queries that are created when you run the API [2]

    It's a proof of concept that I've used to build APIs with a lot of dynamic filters and complex sub-queries, I'd love to know your thoughts on it!

    [1]: https://github.com/gajus/slonik

    [2]: https://sql-api-playground.netlify.app/

  • Sneakiest development trap: making easy easier...
    1 project | dev.to | 4 Jan 2024
    And sometimes invest instead in learning a technology rather than hide it: for example slonik encourages you to write normal SQL queries by making SQL templating easier and safer. In turn, your IDE would be able to understand those queries and give you support based on the database schemas you actually have.
  • Drizzle is just as unready for prime-time as Prisma, what else is there?
    12 projects | /r/reactjs | 6 Dec 2023
    I'd push you to consider using postgres, slonik or similar for database queries. With these libraries, you just write SQL, but they perform input sanitization for you. So you can safely write:
  • Slonik: PostgreSQL client for Node.js with runtime validation
    1 project | news.ycombinator.com | 14 Oct 2023
  • PostgresJs: The Fastest full featured PostgreSQL client for Node.js and Deno
    16 projects | news.ycombinator.com | 14 Oct 2023
    You can already use postgres with Slonik.

    https://github.com/gajus/slonik#user-content-slonik-how-are-...

    It is not going to be the default because it is way slower.

    https://github.com/gajus/slonik/actions/runs/6616647651

    Test node_version:18 test_only:postgres-integration is taking 3 minutes.

    Test node_version:18 test_only:pg-integration is taking 38 seconds.

  • Integrating Slonik with Express.js
    2 projects | dev.to | 30 Sep 2023
    For those uninitiated, Slonik is a battle-tested SQL query building and execution library for Node.js. Its primary goal is to allow you to write and compose SQL queries in a safe and convenient way. Now, let's see how it pairs with Express.js.
  • Which Postgres client are you using?
    1 project | /r/node | 29 Sep 2023
    I am the maintainer of Slonik and I am trying to understand what portion of this sub-users are using Slonik vs other libraries, and if they are using anything else – what are their reasons for it.
  • A note from our sponsor - SaaSHub
    www.saashub.com | 6 Jun 2026
    SaaSHub helps you find the best software and product alternatives Learn more →

Stats

Basic slonik repo stats
75
4,902
9.3
about 13 hours ago

gajus/slonik is an open source project licensed under GNU General Public License v3.0 or later which is an OSI approved license.

The primary programming language of slonik is TypeScript.


Sponsored
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com

Did you know that TypeScript is
the 2nd most popular programming language
based on number of references?