Skip to content

Installation

Requirements

  • Deno 2.x or Node.js 18+
  • SurrealDB 2.0+

Installing surql

Import directly — no install step required:

import { SurQLClient } from 'jsr:@oneiriq/surql'

For convenience, add an import map to your deno.json:

{
  "imports": {
    "surql": "jsr:@oneiriq/surql",
    "surrealdb": "npm:surrealdb@^2.0.0"
  }
}

Then import with the short alias:

import { SurQLClient } from 'surql'
npm install @oneiriq/surql
# or
yarn add @oneiriq/surql
# or
pnpm add @oneiriq/surql
import { SurQLClient } from '@oneiriq/surql'
npx jsr add @oneiriq/surql

Installing SurrealDB

macOS

brew install surrealdb/tap/surreal

Linux

curl -sSf https://install.surrealdb.com | sh

Windows (PowerShell)

iwr https://windows.surrealdb.com -useb | iex

Docker

docker pull surrealdb/surrealdb:latest

Running SurrealDB

Local Development (memory)

surreal start --user root --pass root memory

Docker

docker run --rm -p 8000:8000 \
  surrealdb/surrealdb:latest \
  start --user root --pass root memory

Docker Compose

services:
  surrealdb:
    image: surrealdb/surrealdb:latest
    ports:
      - "8000:8000"
    command: start --user root --pass root memory

Verify the Connection

import { SurQLClient } from 'jsr:@oneiriq/surql'

const client = new SurQLClient({
  host: 'localhost',
  port: '8000',
  namespace: 'test',
  database: 'test',
  username: 'root',
  password: 'root',
})

const db = await client.getConnection()
const result = await db.query('SELECT * FROM $session')
console.log('Connected:', result)
await client.close()

Next Steps