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:

Create a new Bun CLI starter project by running the following command:

npx bknd create -i bun

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.

// index.ts
import { serve } from "bknd/adapter/bun";

// if the configuration is omitted, it uses an in-memory database
serve({
   connection: {
      url: process.env.DB_URL!,
      authToken: process.env.DB_AUTH_TOKEN!
   }
});

For more information about the connection object, refer to the Database guide.

Run the application using Bun by executing:

bun run index.ts