# Custom domains

Serve a public service at your own domain or subdomain, like `shop.example.com`, with a certificate issued for you.

## Add one

1. Open the service's **Networking → Custom domains** and add the domain.
2. At your domain's DNS provider, create the record it shows:

| Type | Name | Target |
| --- | --- | --- |
| CNAME | `shop` | `domains.smartalfred.com` |

The name is the part before your domain (some providers want the whole hostname).

3. Wait for it: the status goes from **Waiting for DNS** to **Issuing certificate** to **Live**, usually within a few minutes. **Check** asks again right away and shows what your DNS says now.

```diagram domain
You add shop.example.com under the service's Networking, Custom domains. It waits for DNS until your DNS provider has the CNAME record shop pointing at domains.smartalfred.com. Once that's seen, a certificate for HTTPS is issued for you. Within minutes it's live, and https://shop.example.com answers.
```

From the [command line](/docs/cli#domains), `alf domains add shop.example.com` does the same: it says the record to create and waits until the domain is live with HTTPS.

## Root domains

A root domain like `example.com` can't have a CNAME at most providers. Use an ALIAS or ANAME record pointing at `domains.smartalfred.com`, or CNAME flattening (automatic on Cloudflare). Or use `www.example.com` instead.

## Domains on Cloudflare

If your domain's DNS is on Cloudflare, set the record to **DNS only** (grey cloud).

## Good to know

- A domain can belong to one service at a time.
- Private services can't have domains; a service with domains can't be made private until they're removed.
- Removing a domain, or deleting its service or project, frees it at once.
