Files
bknd/docs/integration/bun.mdx
2025-06-13 17:18:29 +02:00

46 lines
1.1 KiB
Plaintext

---
title: 'Bun'
description: 'Run bknd inside Bun'
---
import InstallBknd from '/snippets/install-bknd.mdx';
## Installation
To get started with Bun 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 Bun CLI starter project by running the following command:
```sh
npx bknd create -i bun
```
</Tab>
<Tab title="Manual">
Create a new Bun project and then install bknd as a dependency:
<InstallBknd />
</Tab>
</Tabs>
## Serve the API & static files
The `serve` function of the Bun adapter makes sure to also serve the static files required for
the admin panel.
``` tsx
// index.ts
import { serve } from "bknd/adapter/bun";
// if the configuration is omitted, it uses an in-memory database
serve({
connection: {
url: "file:data.db"
}
});
```
For more information about the connection object, refer to the [Database](/usage/database) guide.
Run the application using Bun by executing:
```bash
bun run index.ts
```