---
title: "Embedding SurrealDB"
description: "How to embed SurrealDB into your application. Detailed instructions for each supported programming language."
canonical_url: "https://surrealdb.com/docs/integrate/embedding"
section: "Embedding SurrealDB"
surrealdb_version: "4.x"
last_modified: "2026-11-18T02:09:16Z"
---

> Full SurrealDB documentation index: https://surrealdb.com/docs/llms.txt

# Embedding SurrealDB

How to embed SurrealDB into your application. Detailed instructions for each supported programming language.

Instead of connecting to a remote server, you can run SurrealDB directly inside your application process. Embedded mode gives you the full query engine with no network overhead, which is useful for local-first applications, edge deployments, and testing.

## Embedding languages

The following languages are supported:

- [.NET](/docs/integrate/embedding/by-language/dotnet.md)
- [Go](/docs/integrate/embedding/by-language/golang.md)
- [Java](/docs/reference/java/concepts/embedded-databases.md)
- [JavaScript](/docs/integrate/embedding/by-language/javascript.md)
- [Python](/docs/integrate/embedding/by-language/python.md)
- [Rust](/docs/integrate/embedding/by-language/rust.md)

The [Swift](/docs/reference/swift.md) and [Kotlin](/docs/reference/kotlin.md) SDKs, which cover iOS and Android apps, connect to a SurrealDB server over HTTP or WebSocket, and do not run a database inside the app.

## Browser embedding options

When embedding SurrealDB in web browsers, you have two options:

**SurrealDB 4.x**

- **SurrealKV over OPFS**: SurrealDB can store and persist data within the web browser with SurrealKV, which keeps its files in the browser's Origin Private File System (OPFS). The database has to run in a dedicated web worker, and one database can be open in one tab at a time.

- **SDK**: Alternatively, you can use the SurrealDB SDK to connect to a remote SurrealDB instance instead of storing data in the browser.

Embedding in a browser uses the JavaScript SDK's [WebAssembly engine](/docs/reference/javascript/engines/wasm.md) (`@surrealdb/wasm`). It connects with `mem://` for an in-memory database or `surrealkv://` for persistent storage, and can run inside a Web Worker so that queries do not block the page. A `surrealkv://` database only opens inside a dedicated worker. IndexedDB (`indxdb://`) was removed in SurrealDB 4.0, and a `surrealkv://` database copies the data of an IndexedDB database with the same name when it is first opened. [Embedded engines](/docs/reference/javascript/concepts/embedded-engines.md#running-in-a-web-worker) shows both setups.

**SurrealDB 3.x**

- **IndexedDB**: SurrealDB can be configured to use IndexedDB to store and persist data within the web browser. SurrealDB first serialises both keys and values into a Uint8Array and uses IndexedDB as a binary key-value store. This gives good performance, and all of the functionality that SurrealDB offers when it runs in other ways.

- **SDK**: Alternatively, you can use the SurrealDB SDK to connect to a remote SurrealDB instance instead of using IndexedDB for local persistence.

Embedding in a browser uses the JavaScript SDK's [WebAssembly engine](/docs/reference/javascript/engines/wasm.md) (`@surrealdb/wasm`). It connects with `mem://` for an in-memory database or `indxdb://` for IndexedDB persistence, and can run inside a Web Worker so that queries do not block the page. [Embedded engines](/docs/reference/javascript/concepts/embedded-engines.md#running-in-a-web-worker) shows both setups.

## Storage

- [Storage engines](/docs/integrate/embedding/storage-engines.md) - which engine an embedded database can use, and what each gives up
