DnsRecords
Manages DNS records in a Cloudflare zone using the Cloudflare DNS API.
Minimal Example
Section titled “Minimal Example”Create a basic A record pointing to an IP address.
import { DnsRecords } from "alchemy/cloudflare";
const records = await DnsRecords("example-dns", { zoneId: "YOUR_ZONE_ID", records: [ { name: "www.example.com", type: "A", content: "192.0.2.1", proxied: true, }, ],});
Email Records
Section titled “Email Records”Create MX and TXT records for email routing.
import { DnsRecords } from "alchemy/cloudflare";
const emailRecords = await DnsRecords("email-dns", { zoneId: "YOUR_ZONE_ID", records: [ { name: "example.com", type: "MX", content: "aspmx.l.google.com", priority: 1, }, { name: "example.com", type: "TXT", content: "v=spf1 include:_spf.google.com ~all", }, ],});
Proxied Records
Section titled “Proxied Records”Create proxied records to take advantage of Cloudflare’s CDN and security features.
import { DnsRecords } from "alchemy/cloudflare";
const proxiedRecords = await DnsRecords("proxied-dns", { zoneId: "YOUR_ZONE_ID", records: [ { name: "www.example.com", type: "A", content: "192.0.2.1", proxied: true, ttl: 1, // Auto TTL when proxied }, { name: "blog.example.com", type: "CNAME", content: "www.example.com", proxied: true, }, ],});