Skip to main content

Installation

Kysely can be installed using any major JavaScript package manager. Choose your preferred package manager below.

Package Manager Installation

npm install kysely

Database Driver Installation

Kysely requires a database driver to connect to your database. Install the appropriate driver for your database:
npm install pg
For TypeScript users, you may also want to install @types/pg as a dev dependency.

Deno Installation

For Deno users, add Kysely to your deno.json imports:
deno.json
{
  "imports": {
    "kysely": "npm:kysely@^0.28.0",
    "pg-pool": "npm:pg-pool@^3.6.0"
  }
}
Replace version numbers with the latest versions. Deno uses different driver imports than Node.js.

TypeScript Configuration

Kysely requires TypeScript 4.6 or later. Ensure your tsconfig.json has these settings:
tsconfig.json
{
  "compilerOptions": {
    "target": "ES2020",
    "module": "commonjs",
    "lib": ["ES2020"],
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true
  }
}
The strict flag is highly recommended to get the full benefits of Kysely’s type-safety.

Verify Installation

Create a simple test file to verify your installation:
test.ts
import { Kysely } from 'kysely'

console.log('Kysely imported successfully!')
Run the file:
ts-node test.ts
# or
npx tsx test.ts

Next Steps

Quick Start

Set up your database and write your first query

Type Generation

Learn how to generate types from your database schema

Version Compatibility

Current Version: 0.28.xNode.js: Requires Node.js 20.0.0 or laterTypeScript: Requires TypeScript 4.6 or later
For users on older TypeScript versions (< 4.6), Kysely provides compatibility type definitions, but upgrading TypeScript is strongly recommended for the best experience.

Build docs developers (and LLMs) love