# Domain SDK

> Open-source TypeScript SDK for adding, verifying, and monitoring customer domains across Vercel, Cloudflare, Railway, Render, Netlify, and bunny.net, with DNS writes for Porkbun, Namecheap, and Spaceship.

Reach for Domain SDK (`@opencoredev/domain-sdk`) when a server-side TypeScript app needs to add, verify, monitor, and remove customer custom domains on Vercel, Cloudflare for SaaS, Railway, Render, Netlify, or bunny.net, or write DNS records at Porkbun, Namecheap, or Spaceship. Install with `bun add @opencoredev/domain-sdk` and import each provider from its own subpath, such as `@opencoredev/domain-sdk/vercel`.

- Package: `@opencoredev/domain-sdk`, MIT license, server-side Node.js 20+ or Bun.
- Domain SDK manages domain lifecycle calls and normalized DNS instructions. It does not register domains, host DNS, proxy traffic, or store tenant data.
- `createDomainClient({ provider })` returns `add`, `get`, `list`, `verify`, `remove`, and `waitUntilActive`; `createDnsClient()` writes the returned records into a registrar zone.
- `memoryProvider()` from `@opencoredev/domain-sdk/testing` runs without network access, for tests.
- Install the agent skill: `npx skills add opencoredev/domain-sdk --skill domain-sdk`.
- The blog at https://www.domain-sdk.dev/blog has longer guides on custom domains for SaaS apps and registrar DNS APIs. RSS: https://www.domain-sdk.dev/blog/rss.xml
- The human-readable sitemap at https://www.domain-sdk.dev/sitemap groups every page by topic.

Every page below is also available as Markdown: append `.md` to its URL.

## Domain SDK

- [Custom domains and DNS SDK for TypeScript](https://www.domain-sdk.dev/docs): Domain SDK docs. Add and verify SaaS customer domains on Vercel, Cloudflare, Railway, Render, and Netlify, and write DNS records at Porkbun, Namecheap, and Spaceship.
- [Install Domain SDK for TypeScript](https://www.domain-sdk.dev/docs/installation): Install the server-side TypeScript SDK and start managing SaaS customer domains with Vercel, Cloudflare, Railway, Render, Netlify, or bunny.net.

### Guides

- [Custom domain implementation guides](https://www.domain-sdk.dev/docs/guides): Build secure SaaS custom-domain workflows with practical TypeScript guides for setup, DNS, polling, persistence, testing, and troubleshooting.
- [Build a custom-domain settings page](https://www.domain-sdk.dev/docs/guides/custom-domain-settings-page): Connect an authenticated tenant endpoint to Domain SDK without exposing credentials.
- [Add and remove customer domains](https://www.domain-sdk.dev/docs/guides/add-remove-domains): Use safe idempotency without silently claiming domains from another resource.
- [Display DNS records correctly](https://www.domain-sdk.dev/docs/guides/display-dns-records): Give customers complete instructions without registrar-specific assumptions.
- [Store domain state in your database](https://www.domain-sdk.dev/docs/guides/store-domain-state): Persist tenant ownership and cached UI state while keeping the provider authoritative.
- [Poll until a domain is active](https://www.domain-sdk.dev/docs/guides/poll-until-active): Wait until a custom domain reaches the provider-reported active state with waitUntilActive: timeouts, intervals, AbortSignal cancellation, and Retry-After backoff.
- [Troubleshoot pending DNS](https://www.domain-sdk.dev/docs/guides/troubleshoot-dns): Diagnose routing and ownership records that remain pending or invalid.
- [Troubleshoot custom domain SSL certificates](https://www.domain-sdk.dev/docs/guides/troubleshoot-certificates): Check when a custom domain's SSL certificate is ready with domain.certificate.status, and fix certificates stuck pending: routing, ownership, CAA, DNSSEC, and proxies.
- [Handle apex domains and subdomains](https://www.domain-sdk.dev/docs/guides/apex-and-subdomains): Respect adapter capabilities without guessing public-suffix boundaries.
- [Give tenants managed subdomains](https://www.domain-sdk.dev/docs/guides/managed-subdomains): Give each tenant a subdomain like acme.mydomain.com with createSubdomainClient: reserved labels, a single wildcard, or one hostname per tenant.
- [Tenant authorization and domain security](https://www.domain-sdk.dev/docs/guides/tenant-security): Secure customer custom domains in a multi-tenant app: authorize every call by tenant, rate-limit changes, and prevent abandoned-domain takeover.
- [Production credential setup](https://www.domain-sdk.dev/docs/guides/production-credentials): Scope and store platform credentials for server-side domain management.
- [Switch providers safely](https://www.domain-sdk.dev/docs/guides/switch-providers): Build a deliberate migration without pretending Domain SDK moves live traffic.
- [Test without external API calls](https://www.domain-sdk.dev/docs/guides/test-without-network): Simulate latency, failures, transitions, and calls with isolated memory providers.

### Components

- [Custom domain UI components](https://www.domain-sdk.dev/docs/components): Add accessible, copy-ready DNS instructions and optional one-click DNS setup to a React custom-domain settings page.
- [DNS records UI component](https://www.domain-sdk.dev/docs/components/dns-records-table): Add a copy-ready React DNS records table to your SaaS domain settings page so customers can configure routing, ownership, and certificates.
- [One-click DNS setup component](https://www.domain-sdk.dev/docs/components/one-click-dns-setup): Send customers from your SaaS domain settings page to a supported DNS provider for reviewed, automatic record configuration.

### Providers

- [Custom domain provider comparison](https://www.domain-sdk.dev/docs/providers): Compare custom domain support across Vercel, Cloudflare for SaaS, Railway, Render, Netlify, and bunny.net, plus the Porkbun, Namecheap, and Spaceship DNS adapters.
- [Vercel custom domains: DNS records, limits, and the API](https://www.domain-sdk.dev/docs/providers/vercel): Add a custom domain to Vercel: an A record for the apex (76.76.21.21 or your project's value), a CNAME for subdomains, the _vercel TXT check, limits, and the API.
- [Cloudflare for SaaS custom hostnames: setup and API](https://www.domain-sdk.dev/docs/providers/cloudflare): How Cloudflare for SaaS custom hostnames work: the fallback origin, the CNAME target your customers point to, hostname and certificate validation, and a TypeScript client for the Custom Hostnames API.
- [Railway domains: custom domain DNS, SSL, and the API](https://www.domain-sdk.dev/docs/providers/railway): Add a custom domain to Railway: a CNAME to your up.railway.app target, a TXT record for ownership, CNAME flattening or ALIAS at the root, automatic SSL, and the API.
- [Render custom domain: DNS records, verification, and the API](https://www.domain-sdk.dev/docs/providers/render): Add a custom domain to Render: CNAME to your onrender.com subdomain, ALIAS or A 216.24.57.1 for a root domain, then Verify. Plan limits, SSL, and the API.
- [Netlify custom domain: DNS records, 75.2.60.5, and the API](https://www.domain-sdk.dev/docs/providers/netlify): Point a custom domain at Netlify: a CNAME to your .netlify.app subdomain, or for an apex domain an ALIAS to apex-loadbalancer.netlify.com or an A record to 75.2.60.5. SSL, site ID, and the API.
- [bunny.net custom domains](https://www.domain-sdk.dev/docs/providers/bunny): Add, verify, monitor, and remove customer hostnames on a bunny.net CDN pull zone with a typed server-side TypeScript adapter.
- [Porkbun DNS records: the TypeScript adapter](https://www.domain-sdk.dev/docs/providers/porkbun): Write Porkbun DNS records (A, AAAA, CNAME, ALIAS, TXT, CAA) from TypeScript: API keys, per-domain API Access, nameserver checks, TTLs from 600 seconds, and errors.
- [Namecheap DNS records: BasicDNS API adapter](https://www.domain-sdk.dev/docs/providers/namecheap): Set Namecheap DNS records (A, AAAA, CNAME, ALIAS, TXT, CAA) from TypeScript: why the API needs BasicDNS, IP whitelisting, whole-list setHosts writes, and limits.
- [Spaceship API: DNS records from TypeScript](https://www.domain-sdk.dev/docs/providers/spaceship): Write DNS records with the Spaceship API from TypeScript: API key and secret headers, dnsrecords permissions, save and delete calls, rate limits, and the SDK adapter.
- [Testing provider](https://www.domain-sdk.dev/docs/providers/testing): Exercise domain flows without credentials, network calls, or shared state.

### Concepts

- [Custom domain architecture concepts](https://www.domain-sdk.dev/docs/concepts): Understand the domain lifecycle, DNS records, ownership verification, managed TLS, provider capabilities, status, errors, and tenant security.
- [Domain lifecycle](https://www.domain-sdk.dev/docs/concepts/domain-lifecycle): How a custom domain moves from add through DNS setup, verification, and waitUntilActive to remove, and how the SDK handles repeat adds and conflicts.
- [Platform providers](https://www.domain-sdk.dev/docs/concepts/platform-providers): Understand what adapters normalize and what remains provider-specific.
- [DNS records in the SDK: types, status, and zone writes](https://www.domain-sdk.dev/docs/concepts/dns-records): The DNS records Domain SDK returns for a custom domain: type, full name, value, purpose, and status. Show them to customers, or write them to a DNS zone with createDnsClient.
- [Ownership verification](https://www.domain-sdk.dev/docs/concepts/ownership-verification): Prove a customer controls a hostname without collecting registrar credentials.
- [Managed certificates](https://www.domain-sdk.dev/docs/concepts/managed-certificates): Track provider-managed TLS issuance separately from DNS and ownership.
- [Status model](https://www.domain-sdk.dev/docs/concepts/status-model): Use overall, verification, certificate, and DNS-record states without false precision.
- [Error handling](https://www.domain-sdk.dev/docs/concepts/error-handling): Handle DomainSdkError codes for auth, conflicts, rate limits, timeouts, and provider outages, with retryable flags, retryAfter, and redacted details.
- [Provider capabilities](https://www.domain-sdk.dev/docs/concepts/provider-capabilities): Detect optional list, verification, certificate, apex, and wildcard behavior.
- [Security model](https://www.domain-sdk.dev/docs/concepts/security-model): Keep provider credentials server-side and tenant ownership in your application.

### API Reference

- [Domain SDK TypeScript API reference](https://www.domain-sdk.dev/docs/api-reference): Reference the typed clients, provider contract, domain model, DNS records, lifecycle status, errors, polling, and isolated testing utilities.
- [createDomainClient](https://www.domain-sdk.dev/docs/api-reference/create-domain-client): Create a stateless client from a provider and optional silent-by-default logger.
- [createSubdomainClient](https://www.domain-sdk.dev/docs/api-reference/create-subdomain-client): Scope tenant hostname operations to direct children of one owned parent domain.
- [DomainClient](https://www.domain-sdk.dev/docs/api-reference/domain-client): DomainClient reference: add, get, refresh, list, verify, remove, and waitUntilActive for customer custom domains, with normalized results on every provider.
- [DomainProvider](https://www.domain-sdk.dev/docs/api-reference/domain-provider): DomainProvider contract: the add, get, list, verify, and remove methods and the capabilities a platform adapter implements to plug into Domain SDK.
- [Domain](https://www.domain-sdk.dev/docs/api-reference/domain): Domain type reference: the provider-independent state every lifecycle read returns, including status, DNS records, verification, certificate, and issues.
- [DnsRecord](https://www.domain-sdk.dev/docs/api-reference/dns-record): DnsRecord type reference: record type, name, value, TTL, purpose (routing, ownership, certificate), and status, ready to show in a custom-domain settings UI.
- [DomainStatus](https://www.domain-sdk.dev/docs/api-reference/domain-status): DomainStatus values, from pending and pending_dns to active, misconfigured, and failed. Only active means a custom domain is ready for production traffic.
- [DomainSdkError](https://www.domain-sdk.dev/docs/api-reference/domain-sdk-error): Structured, sanitized failures shared by the core and provider adapters.
- [waitUntilActive](https://www.domain-sdk.dev/docs/api-reference/wait-until-active): Sequential polling with timeout, cancellation, callback, and retry backoff.
- [Testing utilities](https://www.domain-sdk.dev/docs/api-reference/testing-utilities): Test custom-domain code without network calls using memoryProvider, createMockDomain, createMockDnsRecord, and createFailingProvider from the testing subpath.

### Project

- [Domain SDK project](https://www.domain-sdk.dev/docs/project): Follow Domain SDK releases, inspect the open-source project, and learn how to contribute provider adapters, fixes, documentation, or tests.
- [Contributing](https://www.domain-sdk.dev/docs/project/contributing): Set up the workspace, make a focused change, and run the repository checks.
- [Changelog](https://www.domain-sdk.dev/docs/project/changelog): User-visible Domain SDK releases and compatibility changes.

## Blog

- [Cloudflare for SaaS: custom hostnames, setup, and pricing](https://www.domain-sdk.dev/blog/cloudflare-for-saas): Cloudflare for SaaS in practice: what custom hostnames cost and when pending ones bill, which validation method to pick, why hostnames get stuck, the errors customers hit, and the API calls in TypeScript.
- [Custom domains for SaaS: how to let customers use their own domain](https://www.domain-sdk.dev/blog/custom-domains-for-saas): How to offer customer custom domains in a SaaS app: the DNS records, ownership check, TLS certificate and Host routing, four ways to build it, and the TypeScript code.
- [Domain Connect: one-click DNS setup for SaaS custom domains](https://www.domain-sdk.dev/blog/domain-connect): How Domain Connect works for a SaaS app: discovery, templates, signed apply URLs, Cloudflare onboarding, and TypeScript code that sends customers to approve DNS records.
- [Domain verification with TXT records: how SaaS apps verify customer domains](https://www.domain-sdk.dev/blog/domain-verification): Verify that a customer owns their custom domain with a DNS TXT record: the token, the DNS check, re-verification, and the TXT records Vercel, Cloudflare and Railway need.
- [GoDaddy API: API keys and DNS records from TypeScript](https://www.domain-sdk.dev/blog/godaddy-api): How the GoDaddy API works in 2026, from Personal Access Tokens and scopes to account rules and the v3 DNS records endpoints, with fetch samples and a Domain SDK adapter you can copy.
- [Namecheap API: access, keys, and DNS in TypeScript](https://www.domain-sdk.dev/blog/namecheap-api): Namecheap API access requirements and rate limits, how to get an API key and whitelist your IP, and managing DNS with getHosts and setHosts in TypeScript.
- [Namecheap vs Porkbun for developers: API access, DNS, and automation](https://www.domain-sdk.dev/blog/namecheap-vs-porkbun): A developer's comparison of Namecheap and Porkbun: who can use each API, IP whitelisting, sandboxes, JSON vs XML, per-record vs whole-zone DNS writes, and rate limits.
- [Porkbun API: create DNS records from TypeScript](https://www.domain-sdk.dev/blog/porkbun-api): How to get Porkbun API keys, turn on API access for a domain, and create, list, and delete DNS records with fetch or Domain SDK.
- [Railway API: add custom domains with GraphQL from TypeScript](https://www.domain-sdk.dev/blog/railway-api): Use the Railway public GraphQL API to add a custom domain, read its DNS records and certificate status, and remove it from TypeScript, with tokens and rate limits.
- [Vercel Platforms Starter Kit: add customer custom domains](https://www.domain-sdk.dev/blog/vercel-platforms-custom-domains): The Vercel Platforms Starter Kit only does subdomains. Add customer custom domains with the Vercel API: attach the hostname, show its DNS records, and route it in proxy.ts.
- [What is an apex domain? Apex DNS records explained](https://www.domain-sdk.dev/blog/apex-domain): An apex domain is the root of a DNS zone, like customer.com. Why it can't hold a CNAME, and which apex record (A, ALIAS, or flattened CNAME) each host asks for.
- [Wildcard subdomains for multi-tenant apps: DNS, SSL, and routing](https://www.domain-sdk.dev/blog/wildcard-subdomains): How a wildcard subdomain (*.example.com) works, why its SSL certificate needs DNS-01, the records Vercel, Render, Railway, Netlify, and bunny.net need, and tenant routing.

## RSS Feeds

- [Domain SDK — Blog](https://www.domain-sdk.dev/blog/rss.xml)

## Agent resources

- [llms-full.txt](https://www.domain-sdk.dev/llms-full.txt): The full Markdown of every page in one file.
- [Page Markdown](https://www.domain-sdk.dev/index.md): Append `.md` to any page URL to fetch that page as raw Markdown.
- [JSON API](https://www.domain-sdk.dev/api/docs/pages.json): Page index of the JSON docs API; each entry links the page's JSON and Markdown forms. Described by the OpenAPI document at https://www.domain-sdk.dev/openapi.json.
- [MCP server](https://www.domain-sdk.dev/mcp): Streamable HTTP Model Context Protocol server with search_docs, get_page, list_pages, and get_navigation tools, plus every page as a resource. Discovery document: https://www.domain-sdk.dev/.well-known/mcp.json
- [Agent skills](https://www.domain-sdk.dev/.well-known/agent-skills/index.json): Agent Skills discovery index of the skills this site publishes.
- [API catalog](https://www.domain-sdk.dev/.well-known/api-catalog): RFC 9727 linkset of the APIs documented here.
- [AI catalog](https://www.domain-sdk.dev/.well-known/ai-catalog.json): ARD manifest of the agent-facing resources on this site (MCP server, skills, APIs).
- [agent-readability.json](https://www.domain-sdk.dev/agent-readability.json): Manifest of every agent-facing artifact on this site.
- [Sitemap](https://www.domain-sdk.dev/sitemap.xml): Every indexable page URL with its last-modified date.
