SurrealDB is designed to be run in many different ways and in many environments. Because the same query engine runs on every storage engine, SurrealDB can be run in embedded mode, from within your JavaScript environments.
You can embed SurrealDB in both browser and server environments.
In browser environments using the Wasm engine, SurrealDB can be run as an in-memory database, or it can persist data with SurrealKV over the browser's Origin Private File System (OPFS). In server environments using the Node.js engine, SurrealDB can be run as an embedded database, backed by an in-memory engine (mem://) or SurrealKV (surrealkv://).
The sections below cover embedding SurrealDB in browser and in server environments.
Browser
In browser environments, using the Wasm engine, you can run SurrealDB in-memory (mem://) or with SurrealKV persistence (surrealkv://). A persistent database has to run in a dedicated web worker.
For more information on how to embed SurrealDB in browser environments, please see the Wasm engine documentation.
Server
In server environments, you can use the Node.js engine to run SurrealDB as an embedded database.
For more information on how to embed SurrealDB in server environments, please see the Node.js engine documentation.