In this section, you will learn how to install the JavaScript SDK in your project.
First, install the SurrealDB SDK using your favorite package manager:
bun install surrealdb
npm install --save surrealdb
yarn add surrealdb
pnpm install surrealdb
ImportantThe SurrealDB SDK for JavaScript is also available in the JSR registry as
@surrealdb/surrealdb
.
After installing, you can then import the SDK into your project. Depending on your setup and environment, we supported multiple options.
import Surreal from 'surrealdb';
const { Surreal } = require('surrealdb');
//Importing from Deno import Surreal from "https://deno.land/x/surrealdb/mod.ts"; // Import with version import Surreal from "https://deno.land/x/surrealdb@1.0.0/mod.ts";
import Surreal from "https://unpkg.com/surrealdb"; // or import Surreal from "https://cdn.jsdelivr.net/npm/surrealdb";
NoteIt is recommended to import this in a utility file or a file that is shared across your application.
After installing the SDK, check out the quick start guide to build your a simple application with the SDK. You can also learn more about carrying out common tasks with the SDK in the following sections: