Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.bunny.net/llms.txt

Use this file to discover all available pages before exploring further.

You can connect Edge Scripts to your database by adding credentials as environment variables directly from the database dashboard.
1

Go to the Access page

Navigate to Dashboard > Edge Platform > Database > [Select Database] > Access.
2

Generate tokens

Click Generate Tokens to create new access credentials for your database.
Generate Tokens
3

Add to script

Once the tokens are generated, click Add Secrets to Edge Script.
Add to
Script
4

Select your script

Choose the Edge Script you want to connect to your database.
Select Script
5

Access the environment variables

The database URL and access token are now available as environment variables in your script. Use them to connect to your database:
import { createClient } from "@libsql/client/web";
import process from "node:process";

const client = createClient({
  url: process.env.BUNNY_DATABASE_URL,
  authToken: process.env.BUNNY_DATABASE_AUTH_TOKEN,
});

const result = await client.execute("SELECT * FROM users");