Skip to content

Web3Hostname

Source: src/Cloudflare/Web3/Hostname.ts

A Cloudflare Web3 gateway hostname — serve Ethereum or IPFS content from a hostname on your zone via Cloudflare’s distributed web gateways.

A hostname’s identity is its name within the zone; only dnslink and description are mutable, so changing name, target, or zoneId triggers a replacement. Hostnames activate asynchronously: they start in pending status and flip to active once the CNAME is verified.

Note: Cloudflare has restricted Web3 gateways for new customers — on accounts without the entitlement, creation fails with the typed Web3HostnameNotEntitled error.

Safety: Web3 hostnames carry no ownership markers. When there is no prior state, read scans the zone for an existing hostname with the same name and reports it as Unowned, so the engine refuses to take it over unless --adopt (or adopt(true)) is set.

IPFS hostname pinned to a DNSLink

const gateway = yield* Cloudflare.Web3Hostname("IpfsGateway", {
zoneId: zone.zoneId,
name: "ipfs.example.com",
target: "ipfs",
dnslink: "/ipns/onboarding.ipfs.cloudflare.com",
description: "IPFS gateway for example.com",
});

IPFS universal-path gateway

// Serves any CID under /ipfs/... and /ipns/... paths.
const universal = yield* Cloudflare.Web3Hostname("UniversalGateway", {
zoneId: zone.zoneId,
name: "gateway.example.com",
target: "ipfs_universal_path",
});
yield* Cloudflare.Web3Hostname("EthGateway", {
zoneId: zone.zoneId,
name: "eth.example.com",
target: "ethereum",
});