Getting Started
@tsdrivers/mssql is a SQL Server driver for TypeScript runtimes (Deno, Node.js 22+, Bun) that uses a native Rust library via FFI for high performance.
Quick Start
ts
import * as mssql from "@tsdrivers/mssql";
await using pool = await mssql.createPool(
"Server=localhost;Database=mydb;User Id=sa;Password=pass;TrustServerCertificate=true;",
);
const users = await pool.query<{ name: string }>("SELECT name FROM Users");
console.log(users);The unified @tsdrivers/mssql package automatically detects your runtime (Deno, Node.js, or Bun) and loads the correct FFI adapter. See Runtime-Specific Packages for advanced usage.
Architecture
The library has three layers:
Rust cdylib — Communicates with SQL Server via the Microsoft ODBC Driver 18 through the odbc-api crate. Exposes a C ABI with 24 FFI functions.
Core TypeScript — Runtime-agnostic business logic: connection/pool classes, query serialization, config parsing, binary resolution. Shared by all three runtime adapters.
Runtime adapters — Thin FFI wrappers for each runtime:
- Deno:
Deno.dlopen(nonblocking via V8 thread pool) - Node.js + Bun: koffi (nonblocking via worker threads)
- Deno:
Next Steps
- Installation — Install the native library
- Connections — Connect to SQL Server
- Queries — Execute queries and commands