• Start

Engines

WebAssembly

The SurrealDB SDK for JavaScript using the WebAssembly engine.

The @surrealdb/wasm package is a plugin for the JavaScript SDK that runs SurrealDB as an embedded database within a browser environment. It supports in-memory databases and persistent storage via IndexedDB, and can optionally run inside a Web Worker.

Important

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

First, install the JavaScript SDK if you haven't already. Then add the WASM engine:

npm install --save @surrealdb/wasm
import { Surreal, createRemoteEngines } from 'surrealdb';
import { createWasmEngines } from '@surrealdb/wasm';

const db = new Surreal({
    engines: {
        ...createRemoteEngines(),
        ...createWasmEngines(),
    },
});

await db.connect('mem://');

Was this page helpful?