> Full SurrealDB documentation index: https://surrealdb.com/docs/llms.txt

# SQL drivers installation

Install @surrealdb/pg or @surrealdb/mysql with npm, Bun, pnpm or Yarn, and check the runtimes they support.

Install the package for the dialect you use. Each package is ESM only and has no runtime dependencies.

**bun**

```bash
bun add @surrealdb/pg
bun add @surrealdb/mysql
```

**npm**

```bash
npm install @surrealdb/pg
npm install @surrealdb/mysql
```

**yarn**

```bash
yarn add @surrealdb/pg
yarn add @surrealdb/mysql
```

**pnpm**

```bash
pnpm add @surrealdb/pg
pnpm add @surrealdb/mysql
```

`pg` is an optional peer dependency of `@surrealdb/pg`. It is needed only for the [Prisma path](/docs/libraries/sql-drivers/orm-compatibility.md#prisma), and Drizzle's node-postgres driver imports it itself.

## Requirements

| Requirement | Version |
| --- | --- |
| Runtime | Node.js 20 or later, Bun, Deno, Cloudflare Workers, Vercel Edge, or a browser |
| SurrealDB server | A version that serves the `pgsql` and `mysql` RPC methods |

The packages use `fetch`, `WebSocket`, `AbortController` and `TextEncoder`, and no Node.js built-ins. Node.js versions without a global `WebSocket` need a constructor passed as the `WebSocket` option, for example from the `ws` package. HTTP alone needs nothing extra.

```ts title="Use ws on a Node.js version without a global WebSocket"
import WebSocket from "ws";
import { connect } from "@surrealdb/pg";

const sql = connect({ url: "surrealdb+wss://abc123.surrealdb.earth/prod/app", WebSocket });
```

Each package is about 11 kB minified and compressed with brotli.

> [!WARNING]
> Do not put database credentials in browser code that real users can read. Pass a token, or a function that returns one, as the `auth` option.

## Check the instance

Call `capabilities()` to check that an instance serves the method before you rely on it.

```ts
const caps = await sql.capabilities();
// { supported: true, version: "...", transport: { ... } }
```

It reports `supported: false` with a reason when the method or the dialect route is denied, for example with `--deny-rpc pgsql`.
