> ## Documentation Index
> Fetch the complete documentation index at: https://docs-terra.withunify.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom Domains

> Configure custom domains for workspaces and forms

# Custom Domains

> Forms can be served from agency-owned domains like `apply.example.gov`.

## Domain Hierarchy

1. **Form domain** — Highest priority
2. **Workspace domain** — Fallback
3. **App domain** — Default

## Workspace Domains

Apply a domain to all forms in a workspace:

1. Go to **Workspace Settings** → **Custom Domain**
2. Enter your domain (e.g., `apply.example.gov`)
3. Add DNS records
4. Verify ownership

## Form Domains

Override workspace domain for a specific form:

1. Go to **Form Settings** → **Custom Domain**
2. Enter your domain
3. Add DNS records
4. Verify ownership

## DNS Configuration

Add these records to your DNS provider:

| Type  | Name     | Value                |
| ----- | -------- | -------------------- |
| CNAME | apply    | cname.vercel-dns.com |
| TXT   | \_vercel | verification-token   |

## Verification

Domains go through verification:

```mermaid theme={null}
stateDiagram-v2
    [*] --> pending: Add domain
    pending --> active: DNS verified
    pending --> invalid: Verification failed
    invalid --> pending: Retry
```

## Middleware Routing

Custom domains are resolved in middleware:

```typescript theme={null}
const host = request.headers.get("host");

// Check form-level domain
const form = await getFormByDomain(host);
if (form) return rewriteToForm(form);

// Check workspace-level domain
const workspace = await getWorkspaceByDomain(host);
if (workspace) return rewriteToWorkspace(workspace);

// Use default routing
return NextResponse.next();
```

***

<CardGroup cols={2}>
  <Card title="Multi-Tenancy" icon="building" href="/core-systems/identity/multi-tenancy">
    Organization structure
  </Card>

  <Card title="Public Pages" icon="globe" href="/features/form-lifecycle/public-pages">
    Applicant-facing pages
  </Card>
</CardGroup>
