Type-safe DNS
from your editor.
Full TypeScript types for every record, zone, domain, cert, and monitor. Autocomplete for record types. Discriminated unions for errors. Zero runtime deps.
Install. Import.
Ship.
One package. One import. Full access to the Relays API with typed responses, automatic pagination, and retries with exponential backoff.
Create. Read. Update.
Delete.
Every method returns a typed response. Create returns the full record. Update returns a new snapshot. Delete is soft and restorable.
Wait for
propagation.
Pass waitForPropagation: true on any write and the SDK polls global resolvers until the change is confirmed everywhere.
const record = await relays.records.create(
"example.com",
{
type: "A",
name: "api",
content: "142.93.18.201",
ttl: 3600,
},
{ waitForPropagation: true }
);
// record.propagation_ms => 3812
// Resolves only after all 8 global
// resolvers return the correct answer.Typed errors.
instanceof checks.
Every API error is a typed class you can catch with instanceof. Rate limit errors include retryAfter. Validation errors include the field and reason.
for await
(const event of stream)
The SDK exposes the WebSocket event stream as a native AsyncIterator. Type-narrowed events, automatic reconnection, and backpressure.
const stream = relays.events.stream({
zones: ["example.com"],
types: ["dns.*", "monitor.*"],
});
for await (const event of stream) {
switch (event.type) {
case "dns.record.created":
// event.data is DnsRecordCreated
deploy(event.data.record);
break;
case "monitor.down":
// event.data is MonitorDown
page(event.data.monitor_id);
break;
}
}
// Auto-reconnects with resume token.
// Ctrl-C or stream.close() to stop.