Guide

Installation

Learn how to install Nuxt SurrealDB in your Nuxt application

Setup

Installation

Install nuxt-surrealdb in your Nuxt application.

pnpm add nuxt-surrealdb

Getting started

Add nuxt-surrealdb to your modules in nuxt.config.ts:

nuxt.config.ts
export default defineNuxtConfig({
  modules: [
    'nuxt-surrealdb',
  ],
})

Then configure your SurrealDB endpoint:

nuxt.config.ts
export default defineNuxtConfig({
  modules: ['nuxt-surrealdb'],
  surrealdb: {
    client: {
      endpoint: 'http://localhost:8000',
      connectOptions: {
        namespace: 'my_ns',
        database: 'my_db',
      },
    },
  },
})

That's it! You can now use Nuxt SurrealDB in your Nuxt app.

Optional peer dependencies

The core module uses the surrealdb JavaScript SDK to connect to a remote SurrealDB instance. For embedded (in-process) engines, install the optional peer dependencies:

Client-side WASM engine

To run SurrealDB in-memory or with IndexedDB storage on the client side:

pnpm add @surrealdb/wasm
The IndexedDB (indxdb://) WASM engine is currently not fully supported with SurrealDB 3.0. In-memory (mem://) mode works as expected.

Server-side Node engine

To run SurrealDB in-memory or with SurrealKV local storage on the server side:

pnpm add @surrealdb/node

The module auto-detects which packages are available and enables the corresponding features automatically.