-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
--- | ||
sidebar_position: 2 | ||
sidebar_label: Installation | ||
title: JavaScript | SDKs | Installation | ||
description: In this section, you will learn how to install the JavaScript SDK in your project. | ||
--- | ||
|
||
# Installation | ||
|
||
In this section, you will learn how to install the JavaScript SDK in your project. | ||
|
||
### Install the SDK | ||
|
||
First, install the [SurrealDB SDK](https://npmjs.com/package/surrealdb) using your favorite package manager: | ||
|
||
import Tabs from "@components/Tabs/Tabs.astro"; | ||
import TabItem from "@components/Tabs/TabItem.astro"; | ||
|
||
<Tabs groupId="node-package-manager"> | ||
<TabItem value="bun" label="bun"> | ||
|
||
```bash | ||
bun install surrealdb | ||
``` | ||
|
||
</TabItem> | ||
<TabItem value="npm" label="npm" default> | ||
|
||
```bash | ||
npm install --save surrealdb | ||
``` | ||
|
||
</TabItem> | ||
<TabItem value="yarn" label="yarn"> | ||
|
||
```bash | ||
yarn add surrealdb | ||
``` | ||
|
||
</TabItem> | ||
<TabItem value="pnpm" label="pnpm"> | ||
|
||
```bash | ||
pnpm install surrealdb | ||
``` | ||
|
||
</TabItem> | ||
</Tabs> | ||
|
||
> [!IMPORTANT] | ||
> The SurrealDB SDK for JavaScript is also available in the JSR registry as [`@surrealdb/surrealdb`](https://jsr.io/@surrealdb/surrealdb). | ||
<br /> | ||
|
||
### Import the SDK to your project | ||
|
||
After installing, you can then import the SDK into your project. Depending on your setup and environment, we supported multiple options. | ||
|
||
<Tabs groupId="node-package-manager"> | ||
<TabItem value="es6" label="ES6" default> | ||
|
||
```ts | ||
import Surreal from 'surrealdb'; | ||
``` | ||
|
||
</TabItem> | ||
<TabItem value="bun" label="CommonJS" > | ||
|
||
```ts | ||
const { Surreal } = require('surrealdb'); | ||
``` | ||
|
||
</TabItem> | ||
<TabItem value="deno" label="Deno"> | ||
|
||
```ts | ||
//Importing from Deno | ||
import Surreal from "https://deno.land/x/surrealdb/mod.ts"; | ||
|
||
// Import with version | ||
import Surreal from "https://deno.land/x/[email protected]/mod.ts"; | ||
``` | ||
|
||
</TabItem> | ||
<TabItem value="CDN" label="CDN"> | ||
|
||
```ts | ||
import Surreal from "https://unpkg.com/surrealdb"; | ||
// or | ||
import Surreal from "https://cdn.jsdelivr.net/npm/surrealdb"; | ||
``` | ||
|
||
</TabItem> | ||
</Tabs> | ||
|
||
> [!NOTE] | ||
> It is recommended to import this in a utility file or a file that is shared across your application. | ||
|
||
## Next Steps | ||
|
||
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: | ||
- [Quick Start](/docs/sdk/javascript/start) | ||
- [Creating a new connection](/docs/sdk/javascript/core/create-a-new-connection) | ||
- [Authenticating users](/docs/sdk/javascript/core/authenticating-users) |