Files
bknd/docs/integration/node.mdx
2025-02-19 21:27:04 +01:00

49 lines
1.2 KiB
Plaintext

---
title: 'Node'
description: 'Run bknd inside Node'
---
import InstallBknd from '/snippets/install-bknd.mdx';
## Installation
To get started with Node and bknd you can either install the package manually, and follow the descriptions below, or use the CLI starter:
<Tabs>
<Tab title="CLI Starter">
Create a new Node CLI starter project by running the following command:
```sh
npx bknd create -i node
```
</Tab>
<Tab title="Manual">
Create a new Node project and then install bknd as a dependency:
<InstallBknd />
</Tab>
</Tabs>
## Serve the API & static files
The `serve` function of the Node adapter makes sure to also serve the static files required for
the admin panel.
``` tsx
// index.js
import { serve } from "bknd/adapter/node";
// if the configuration is omitted, it uses an in-memory database
/** @type {import("bknd/adapter/node").NodeAdapterOptions} */
const config = {
connection: {
url: "file:data.db"
}
};
serve(config);
```
For more information about the connection object, refer to the [Database](/usage/database) guide.
Run the application using node by executing:
```bash
node index.js
```