◇ /LANDING/SDK/TYPESCRIPT

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.

TypeScript 5.xESM + CJSNode 18+Bun / Deno0 deps
01 · QUICK START

Install. Import.
Ship.

One package. One import. Full access to the Relays API with typed responses, automatic pagination, and retries with exponential backoff.

quick-start.ts
02 · CRUD

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.

crud.ts
03 · PROPAGATION

Wait for
propagation.

Pass waitForPropagation: true on any write and the SDK polls global resolvers until the change is confirmed everywhere.

propagation.ts
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.
04 · ERRORS

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.

errors.ts
05 · STREAMING

for await
(const event of stream)

The SDK exposes the WebSocket event stream as a native AsyncIterator. Type-narrowed events, automatic reconnection, and backpressure.

stream.ts
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.

npm install.
Start building.