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

# Surqlize installation

Install the Surqlize TypeScript ORM with npm, Bun, pnpm or Yarn together with its surrealdb JavaScript SDK peer dependency, and check the supported SDK, TypeScript and SurrealDB server versions.

Surqlize is published on npm as [`surqlize`](https://www.npmjs.com/package/surqlize). It declares the [JavaScript SDK](/docs/reference/javascript/installation.md) as a peer dependency, and your code imports `Surreal` from that package to open the connection, so a project installs both.

## Install the packages

**bun**

```bash
bun add surqlize surrealdb
```

**npm**

```bash
npm install surqlize surrealdb
```

**yarn**

```bash
yarn add surqlize surrealdb
```

**pnpm**

```bash
pnpm add surqlize surrealdb
```

Surqlize ships ESM and CommonJS builds with type declarations, so it can be imported with either module system.

```ts title="Import Surqlize and the SDK"
import { Surreal } from "surrealdb";
import { orm, table, t } from "surqlize";
```

## Requirements

| Requirement                | Version      |
| -------------------------- | ------------ |
| `surrealdb` JavaScript SDK | `^2.1.0`     |
| TypeScript                 | 5 or 6       |
| SurrealDB server           | 3.0 or later |

The SDK and the server are versioned separately: version 2 of the SDK is the one that connects to a SurrealDB 3.x server.

Surqlize targets SurrealDB 3.x. A few features depend on the server version, and the page for each feature says which. [Computed fields](/docs/libraries/surqlize-typescript/schema.md) need 3.0, filtering or projecting a [live query](/docs/libraries/surqlize-typescript/live-queries.md) needs 3.0, and [`.retry()`](/docs/libraries/surqlize-typescript/request-options.md) recognises a transaction conflict from the structured error that SurrealDB 3.1.0 and later report.

## Use one version of the SDK

The connection that you pass to Surqlize and Surqlize itself must come from the same installed copy of `surrealdb`. When a project installs two different versions of the SDK, TypeScript can report an error where the connection is passed to `orm()`:

```text title="Error output"
Type 'Surreal' is not assignable to type 'SurrealSession'.
  Property '#private' in type 'Surreal' refers to a different member that cannot be accessed from within type 'SurrealSession'.
```

To check which versions a project resolves, run `npm ls surrealdb` (or `bun pm ls --all`).

If a query fails with a `DuplicateSurrealError`, the connection was created by a different copy of `surrealdb` from the one Surqlize imports. See [error handling](/docs/libraries/surqlize-typescript/error-handling.md).

## Next steps

- [Schema](/docs/libraries/surqlize-typescript/schema.md) - Describe your first table.

- [Connections](/docs/libraries/surqlize-typescript/connections.md) - Create the ORM instance from an SDK connection.
