Installation
Effect SQL is distributed as multiple npm packages. You'll need the core package plus an adapter for your specific database.
Core Package
The core package contains shared abstractions used by all database adapters:
npm install @effect/sqlpnpm add @effect/sqlyarn add @effect/sqlbun add @effect/sqlDatabase Adapters
Choose the adapter for your database:
PostgreSQL
npm install @effect/sql-pgThis package uses pg under the hood, which will be installed automatically as a peer dependency.
SQLite
Choose based on your runtime:
npm install @effect/sql-sqlite-nodenpm install @effect/sql-sqlite-bunnpm install @effect/sql-sqlite-react-nativenpm install @effect/sql-sqlite-wasmThe Node.js adapter uses better-sqlite3, which requires native compilation. If you encounter issues, ensure you have the required build tools installed for your platform.
MySQL
npm install @effect/sql-mysql2This package uses mysql2 under the hood.
Microsoft SQL Server
npm install @effect/sql-mssqlClickHouse
npm install @effect/sql-clickhouseCloudflare D1
npm install @effect/sql-d1LibSQL / Turso
npm install @effect/sql-libsqlPeer Dependencies
All packages require effect as a peer dependency. Make sure you have it installed:
npm install effectSome adapters also require @effect/platform for file system operations (used by the migration system):
npm install @effect/platform @effect/platform-nodeTypeScript Configuration
Effect SQL requires TypeScript 5.0 or later. Ensure your tsconfig.json has the following settings:
{
"compilerOptions": {
"strict": true,
"exactOptionalPropertyTypes": true,
"moduleResolution": "bundler", // or "node16" / "nodenext"
"module": "ESNext",
"target": "ES2022"
}
}Verifying Installation
Create a simple test file to verify everything is working:
import { Effect } from "effect"
import { SqlClient } from "@effect/sql"
import { SqliteClient } from "@effect/sql-sqlite-node"
const program = Effect.gen(function* () {
const sql = yield* SqlClient.SqlClient
const result = yield* sql`SELECT 1 + 1 as sum`
console.log("Result:", result)
})
const SqlLive = SqliteClient.layer({
filename: ":memory:"
})
Effect.runPromise(program.pipe(Effect.provide(SqlLive)))Run this with:
npx tsx test.tsIf you see Result: [ { sum: 2 } ], you're all set!
Next Steps
Now that you have Effect SQL installed, head to the Quick Start guide to learn the basics.