ImportDnsRecords
The ImportDnsRecords resource lets you import DNS records from any domain using Cloudflare’s DNS-over-HTTPS API.
Minimal Example
Section titled “Minimal Example”Import all default DNS record types for a domain.
import { ImportDnsRecords } from "alchemy/dns";
const dnsRecords = await ImportDnsRecords("example-com", { domain: "example.com",});
Import Specific Record Types
Section titled “Import Specific Record Types”Import only specified DNS record types.
import { ImportDnsRecords } from "alchemy/dns";
const records = await ImportDnsRecords("example-com", { domain: "example.com", recordTypes: ["A", "MX"],});
Transfer Records to Cloudflare
Section titled “Transfer Records to Cloudflare”Import DNS records and transfer them to a Cloudflare zone.
import { ImportDnsRecords, DnsRecords } from "alchemy/dns";
const dnsRecords = await ImportDnsRecords("dns-records", { domain: "example.com",});
await DnsRecords("transfer-records", { zoneId: zone.id, records: dnsRecords.records,});