# Custom domains

Put an app on a name like api.example.com. It stays the same across restarts, reboots and reinstalls.

## What you need

A domain on Cloudflare. The free plan is fine.

## Add a domain

```sh
$ dukoi expose --domain api.example.com
Pointing api.example.com at hono-api…

Connect the phone to Cloudflare. In the page that opens, pick example.com and click Authorize.

✓ Phone connected to example.com
Pointing api.example.com at hono-api…
✓ hono-api is public

  Public  https://api.example.com

  This URL stays the same across restarts and reboots.
```

1.  The first time, Cloudflare’s login opens in your browser. Pick your domain and click **Authorize**. The phone keeps the certificate.
2.  The phone makes one tunnel for itself and a DNS record for the name.
3.  After that, adding another name under the same domain takes a second.

You can do the same on the phone: open the app, tap **Make public** and pick **Your domain**.

## Good to know

-   Every name must be under the domain you picked at login, like `*.example.com`.
-   A domain replaces the app’s quick link.
-   Dukoi only changes DNS records it made, and won’t take over a name that already points somewhere else.
-   `dukoi expose --off` removes the name and its DNS record.

## Disconnect from Cloudflare

On the phone, go to **Settings → Cloudflare → Disconnect**. Every app loses its domain, Dukoi deletes the DNS records and tunnel it made, and the phone deletes its certificate. Add a domain again to log in fresh, or to switch to another domain.

> One thing to tidy up
> 
> The login’s API token stays in your Cloudflare account, because a token can’t delete itself. Remove it at **dash.cloudflare.com → My Profile → API Tokens**.
