SurrealDB Docs Logo

Enter a search query

Wasm

This library is a plugin for the SurrealDB JavaScript SDK, which can be used to run SurrealDB as an embedded database within a browser environment, not server side environments.

It enables SurrealDB to be run in-memory, or to persist data by running on top of IndexedDB. It allows for a consistent JavaScript and TypeScript API when using the surrealdb.js library by adding support for embedded storage engines (memory, indxdb) alongside the remote connection protocols (http, https, ws, wss).

This library works with ES modules (import), not CommonJS (require).

The Node engine is available on NPM as @surrealdb.wasm and requires the JavaScript SDK to operate.

Example

import { Surreal } from 'surrealdb'; import { surrealdbWasmEngines } from '@surrealdb/wasm'; // Enable the WebAssembly engines const db = new Surreal({ engines: surrealdbWasmEngines(), }); // Now we can start SurrealDB as an in-memory database await db.connect("mem://"); // Or we can start a persisted IndexedDB database await db.connect("indxdb://demo"); // Now use the JavaScript SDK as normal.

Sources

On this page

© SurrealDB GitHub Discord Community Cloud Features Releases Install