> ## Documentation Index
> Fetch the complete documentation index at: https://keyflare.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom Deployments

> Custom Workers and databases for Keyflare

By default, Keyflare deploys

* A Cloudflare Worker named `keyflare`
  * A Master key secret deployed within that Worker
* A Cloudflare D1 database named `keyflare`

# Using a custom Worker

You can deploy custom Keyflare instances (e.g., for different environments or teams) using the `--name` flag:

```bash theme={null}
# Production instance
kfl init --name keyflare-prod

# Staging instance
kfl init --name keyflare-staging
```

Each instance gets its own:

* Worker (e.g., `keyflare-prod.workers.dev`)
* D1 database
* Master key secret

To target a specific instance, use its API URL:

```bash theme={null}
kfl login
# Enter: https://keyflare-prod.workers.dev
```

<Note>
  Instance names must start with a lowercase letter, contain only lowercase letters, numbers, and hyphens, and be 63 characters or less.
</Note>

# Using an Existing D1 Database

If you have a pre-existing D1 database (e.g., from a previous Keyflare instance or migration), you can bind to it using the `--d1id` flag:

```bash theme={null}
kfl init --d1id 12345678-1234-1234-1234-123456789abc
```

This tells Keyflare to use the specified database instead of creating a new one. The deployment will:

1. Build an ephemeral config with the provided `database_id`
2. Deploy the worker bound to that database
3. Run migrations against it (idempotent)

**When to use:**

* Migrating from another Keyflare instance
* Restoring from a backup
* Sharing a database across worker redeployments

**Note:** The database must exist in the same Cloudflare account. If the UUID is invalid, deployment will fail with a clear error.

<h2 noAnchor>Next Steps</h2>

<CardGroup cols={2}>
  <Card href="/guides/security-and-backup" title="Security & Backup">
    Back up your master key and define your recovery strategy.
  </Card>

  <Card href="/guides/custom-domains" title="Custom Domains">
    Serve your Keyflare instance from your own domain.
  </Card>
</CardGroup>
