Installation

Install bknd as a dependency:

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";

const handler = serve({
   connection: {
      type: "libsql",
      config: {
         url: process.env.DB_URL!,
         authToken: process.env.DB_AUTH_TOKEN!
      }
   }
});

Bun.serve({
   port: 1337,
   fetch: handler
});

console.log("Server running at http://localhost:1337");

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

Run the application using Bun by executing:

bun run index.ts