Connect to remote and embedded SurrealDB instances
View the SDK documentation here.
- A Tour of SurrealDB: https://surrealdb.com/learn/tour
- Aeon's Surreal Renaissance (Interactive book): https://surrealdb.com/learn/book
- Documentation: https://surrealdb.com/docs
This monorepo publishes several npm packages. Most applications only need surrealdb - install engine or utility packages when your use case requires them.
| Package | npm | Description | Readme |
|---|---|---|---|
surrealdb |
surrealdb |
Official database client - connect, query, live subscriptions, sessions | Read more |
@surrealdb/sqon |
@surrealdb/sqon |
Value types, CBOR/JSON codecs, and core utilities (re-exported by surrealdb) |
Read more |
@surrealdb/wasm |
@surrealdb/wasm |
Embedded SurrealDB engine for browsers (mem://, indxdb://) |
Read more |
@surrealdb/node |
@surrealdb/node |
Embedded SurrealDB engine for Node.js, Bun, and Deno | Read more |
@surrealdb/spectron |
@surrealdb/spectron |
Typed HTTP client for the Spectron AI memory API | Read more |
bun add surrealdbimport { Surreal } from "surrealdb";
const db = new Surreal();
await db.connect("wss://my-instance.aws-euw1.surreal.cloud");For installation options, connection setup, query examples, live queries, embedded engines, and TypeScript notes, see the surrealdb package readme.
This is a Bun project, not Node.js. It works across all major runtimes, however.
- Bun
- SurrealDB (for testing)
This SDK supports both TypeScript 5 and TypeScript 6. If you are using TypeScript 6, note that the default value for the types compiler option changed from auto-discovering all @types/* packages to []. You may need to explicitly add the types you depend on in your tsconfig.json:
{
"compilerOptions": {
"types": ["node"]
}
}For Deno, no build is needed. For all other environments run:
bun run build
bun run qa - apply formatting and safe fixes
bun run qau - apply formatting and unsafe fixes
bun run qc - check code quality
bun run qts - TypeScript type check
bun run test - WebSocket protocol
SURREAL_DEFAULT_PROTOCOL=http bun test - HTTP protocol
Before you commit, please format and lint your code accordingly to check for errors, and ensure all tests still pass.
For local development the Bun extension and Biome extension for VSCode are helpful.
./biome.json- code quality settings./scripts- build and publish scripts./packages/sdk- JavaScript SDK (surrealdbon npm)./packages/sqon- SQON value types and codecs./packages/node- embedded Node.js engine./packages/wasm- embedded WebAssembly engine./packages/spectron- Spectron HTTP client./packages/tests- test suite (surrealdb/for the SDK,spectron/for Spectron)./demo/wasm- WebAssembly demo./demo/node- Node.js demo