Skip to content

Commit

Permalink
Add installation page
Browse files Browse the repository at this point in the history
  • Loading branch information
Ekwuno committed Oct 21, 2024
1 parent 0b6ea2e commit 5ba7452
Showing 1 changed file with 105 additions and 0 deletions.
105 changes: 105 additions & 0 deletions src/content/doc-sdk-javascript/installation.mdx
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)

0 comments on commit 5ba7452

Please sign in to comment.