Netlify custom domain: DNS records and the API
How to add a custom domain to a Netlify site from code, and the DNS records it needs: a CNAME to your .netlify.app hostname for subdomains, and an ALIAS to apex-loadbalancer.netlify.com or an A record to 75.2.60.5 for apex domains.
Each Netlify custom domain needs a routing record at the customer's DNS provider. A subdomain like app.customer.com gets a CNAME to the site's .netlify.app hostname. An apex domain like customer.com can't use a CNAME, so it gets an ALIAS, ANAME, or flattened CNAME to apex-loadbalancer.netlify.com, or, if the DNS provider supports none of those, an A record to Netlify's load balancer IP 75.2.60.5. Sites on Netlify's High-Performance Edge use a different load balancer, shown in the site's DNS verification details; this adapter always returns the standard one, so check those details for High-Performance Edge sites. The adapter returns the record for the hostname you add, so to serve both customer.com and www.customer.com, add each one and give the customer both records. Netlify then provisions the TLS certificate. These values come from Netlify's external DNS docs, checked 2026-10-29. To add many customer domains from code, this adapter adds each one as a domain alias on your site through the Netlify API and returns the record to show your customer.
Scope and credentials
The adapter manages domain_aliases on one Netlify site. It never replaces the site's primary custom_domain. Set NETLIFY_ACCESS_TOKEN and NETLIFY_SITE_ID; use a token that can read and update only the intended site where possible.
import { createDomainClient } from "@opencoredev/domain-sdk";
import { netlify } from "@opencoredev/domain-sdk/netlify";
export const domains = createDomainClient({
provider: netlify({
accessToken: process.env.NETLIFY_ACCESS_TOKEN!,
siteId: process.env.NETLIFY_SITE_ID!,
}),
});
const domain = await domains.add("app.customer.com");DNS and certificates
Subdomains return a CNAME pointing to the site's .netlify.app hostname. Apex domains return an ALIAS to apex-loadbalancer.netlify.com; when the customer's DNS provider cannot create ALIAS, ANAME, or flattened-CNAME records, use an A record to 75.2.60.5 instead. Apex domains: A records, ALIAS, and CNAME flattening explains which DNS hosts support which record.
Netlify does not expose independent DNS-verification state for each alias. The adapter treats an alias covered by the site's issued TLS certificate as verified and active. Until then, it remains pending_dns; if it stays there, see Troubleshoot custom domain SSL certificates. Netlify manages certificate issuance, so the adapter does not call the certificate provisioning endpoint.
Mutation and alias limits
Netlify updates aliases as one array. Each add or remove reads the current site, preserves unrelated aliases and the primary domain, then writes the updated alias list. Serialize domain mutations for the same site to avoid lost updates from concurrent read-modify-write requests.
Netlify recommends no more than 50 aliases per site. The adapter does not impose a lower limit than the API, but you should use multiple sites if your product regularly exceeds that recommendation.
Official references: Netlify API, domain aliases, and external DNS.
Read next: Store domain state.
Render custom domain: add one with the API
How to add a custom domain to a Render web service or static site through the Render API, point its DNS, verify it, and wait for TLS, with a TypeScript example.
bunny.net custom domains
Add, verify, monitor, and remove customer hostnames on a bunny.net CDN pull zone with a typed server-side TypeScript adapter.
