Skip to content
Home » D1Admin Documentation » Setup D1 Admin

Setup D1 Admin

The setup of D1Admin consists of five easy steps:
(reading time 10 minutes)

  1. Downloading D1Admin Worker Backend
  2. Creating an API key
  3. Configuring D1 instance(s)
  4. Deploying D1Admin Worker Backend
  5. Deploying D1Admin Worker Backend with local D1 instance
  6. Linking with D1Admin

Downloading D1 Admin Backend

Download D1Admin Worker Backend from here (version 1.0.1)

We have to download the Worker Backend code from the link above. It is a NodeJS Cloudflare worker project. One D1Admin Worker Backend by default links the D1Admin DBA tool with one D1 database instance, but it can also serve multiple D1 databases !

Once deployed in our Clouflare account, by default your worker will be accessible with the URL https://[my worker name].[my account name] . We have to specify the worker name in the Worker Backend wrangler.toml file

name = "my worker name"

Configuring API key

D1 Admin requires an API key, which is a random string (at least 8 symbols long, preferably 32 symbols). This API key is used for authenticating the communication between the D1 Admin web interface and the D1 Admin Worker Backend.
Security Note: The API key itself is not transferred during the communication, only a SHA-256 hash of it.

Generating an API key
We can create an API key from the form below

Place API key in wrangler.toml
Once created the API key must be placed inside the wrangler.toml file of the D1 Admin Worker Backend project in the vars sections, like

D1_API_KEY = "my_API_key"

Configuring D1 instance(s)

In addition to the API key that we have configured in the previous step, we must also specify the Cloudflare D1 database instance(s) that the backend will serve. We must copy the D1 database binding configuration in the Worker Backend wrangler.toml file and then we are ready for deployment.

Default D1 instance

The D1 binding configuration should look like below (don’t forget to change database_name and database_id to must match your Claudflare D1 instance, and at least a default binding must exist with fixed value of “DB”):

binding = "DB"
database_name = prod-d1-tutorial"
database_id = "xxxxxxxxxxxxxxxxxx"

Additional D1 instances

A single D1Admin Worker Backend can manage multiple Cloudflare D1 database instances (in addition to the default D1 instance). In order to do so, we have to specify each additional D1 database, by listing it in the Worker backend wrangler.toml file:

binding = "DB1"
database_name = prod-d1-tutorial"
database_id = "xxxxxxxxxxxxxxxxxx"
binding = "DBproduction"
database_name = prod-d1-tutorial"
database_id = "xxxxxxxxxxxxxxxxxx"

If the Worker Backend is running at https://[my worker name].[my account name] (serving the default D1 instance with binding = “DB”), each additional database will be served through a ?DB=[binding] URL parameter, like (using the bindings from the example above):

https://[my worker name].[youraccount name]

https://[my worker name].[youraccount name]

Deployment of D1 Admin Worker Backend

Deployment of the Worker Backend to Cloudflare, is done by executing from the command line:

npx wrangler deploy 

Test deployment:
We can test that the D1 Admin Worker Backend is deployed and running by opening its address in a web browser :

https://[my worker name].[my account]

A successful deployment will display:

Version:<version>:D1Admin Worker Backend is running!

Deployment of the Worker Backend on localhost

When we develop locally (on local development machines) we may also use D1Admin to manage the D1 database(s).

The Steps to do so are to expose the local Worker Backend to be accessible to the outer world and to register it with D1Admin.

To expose the worker we can install a tunneling app like localtunnel:

npm install -g localtunnel

then run the backend with npx wrangler dev

then tunnel the backend:

lt --port 8787

Copy the displayed tunnel URL and register it with D1Admin. Until the tunnel process is running the tunnel URL will be valid for testing and managing your local D1 database instances.

Once the previous steps are complete, we just have to register the Worker Backend in our Customers Area and then we can access the D1Admin DBA tool web interface.

Registering the Worker Backend
After signing into the D1Admin customers area, press the Create button on the top and provide your API key and Worker Backend URL address (or its address with the URL parameter ?DB=<database> when serving additional database, different from the default DB binding)

Then press the Save button and the click then the Open D1 Admin button corresponding to the Cloudflare D1 database that you wish to manage:


This article contains a list of setup instructions for setting up the D1Admin DBA tool web interface in order to for managing Cloudflare D1 database(s).

If you encounter difficulties or cannot connect to your D1 database(s) from D1Admin web interface, please contact us for assistance.