npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mdrv/surrealdb-wasm

v3.0.4

Published

Emeddable WebAssembly browser engine for SurrealDB

Readme

Documentation

View the JavaScript SDK documentation here, including the embedded engines concept page and the WebAssembly engine reference.

What is this package?

@surrealdb/wasm is a WebAssembly engine plugin for the SurrealDB JavaScript SDK. It runs SurrealDB inside the browser - in-memory or persisted to IndexedDB - with the same query API as a remote instance.

Install it alongside surrealdb and register the engine when constructing your client. For server-side embedding, use @surrealdb/node instead.

How to install

This package has a peer dependency on surrealdb. Install both:

# using npm
npm i surrealdb @surrealdb/wasm

# or using pnpm
pnpm i surrealdb @surrealdb/wasm

# or using yarn
yarn add surrealdb @surrealdb/wasm

# or using bun
bun add surrealdb @surrealdb/wasm

Getting started

Register the WebAssembly engine when you create a Surreal client, then connect to an embedded endpoint:

import { createWasmEngines } from "@surrealdb/wasm";
import { Surreal } from "surrealdb";

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

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

await db.use({ namespace: "test", database: "test" });

await db.query("CREATE person SET name = 'Tobie'");

To connect to remote SurrealDB instances as well as embedded databases, combine the WebAssembly engine with the SDK's remote engines:

import { createWasmEngines } from "@surrealdb/wasm";
import { Surreal, createRemoteEngines } from "surrealdb";

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

Storage backends

// In-memory (data is lost when the tab closes)
await db.connect("mem://");

// IndexedDB persistence
await db.connect("indxdb://myapp");

Running in a Web Worker

Offload database work from the main thread to keep your UI responsive:

import { createWasmWorkerEngines } from "@surrealdb/wasm";
import WorkerAgent from "@surrealdb/wasm/worker?worker";
import { Surreal, createRemoteEngines } from "surrealdb";

const db = new Surreal({
    engines: {
        ...createRemoteEngines(),
        ...createWasmWorkerEngines({
            createWorker: () => new WorkerAgent(),
        }),
    },
});

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

The @surrealdb/wasm/worker export provides a pre-built worker script for bundlers that support the ?worker import suffix (such as Vite).

Connection options

Pass optional engine configuration to createWasmEngines or createWasmWorkerEngines:

const db = new Surreal({
    engines: createWasmEngines({
        strict: true,
        query_timeout: 30_000,
    }),
});

Usage with Vite

When using Vite, exclude the WASM package from dependency optimisation and enable top-level await:

// vite.config.js
export default {
    optimizeDeps: {
        exclude: ["@surrealdb/wasm"],
        esbuildOptions: {
            target: "esnext",
        },
    },
    esbuild: {
        supported: {
            "top-level-await": true,
        },
    },
};

Package contents

| Export | Description | | --- | --- | | createWasmEngines(options?) | Registers mem and indxdb engines on the main thread | | createWasmWorkerEngines(options?) | Registers mem and indxdb engines inside a Web Worker | | @surrealdb/wasm/worker | Worker entry point for bundler worker imports | | WebAssemblyEngine | The underlying engine implementation (advanced use) |

Requirements

  • ES modules (import) - CommonJS (require) is not supported
  • A compatible surrealdb SDK version (see peerDependencies in package.json)
  • A modern browser with WebAssembly and IndexedDB support

Contributing

This package is part of the surrealdb.js monorepo. See the main README for local setup, build commands, and contribution guidelines.