DEV Community

Alex Spinov
Alex Spinov

Posted on

Kysely Has a Free API — Type-Safe SQL Query Builder for TypeScript

What if you could write raw SQL in TypeScript and the compiler caught every typo and type mismatch?

Kysely is a type-safe SQL query builder. Not an ORM — full SQL power with full type safety.

  • Full SQL control — complex joins, CTEs, window functions
  • Type-safe everything — table names, columns, where clauses
  • Zero runtime overhead — compiles to plain SQL strings
  • Database agnostic — Postgres, MySQL, SQLite
const users = await db
  .selectFrom("users")
  .innerJoin("posts", "posts.user_id", "users.id")
  .select(["users.name", "posts.title"])
  .where("posts.published", "=", true)
  .execute();
// users is typed as { name: string; title: string }[]
Enter fullscreen mode Exit fullscreen mode

A team switched from raw SQL strings and the compiler caught 23 query bugs during migration.

Visit kysely.dev — zero dependencies.


Need custom data pipelines or scraping solutions? Check out my Apify actors or email me at spinov001@gmail.com for custom solutions.

Top comments (0)