Nasaq

DnsManagement

A DNS zone editor with a searchable records table (A, AAAA, CNAME, MX, TXT and more), an add and edit form with type-aware validation, TTL choices, a proxy toggle and confirmed delete.

PreviewOpen ↗

Code

import { DnsManagement, type DnsRecord } from "@fadymondy/nasaq/web";declare const records: DnsRecord[];declare const api: { save(zone: string, input: unknown): Promise<void>; remove(id: string): Promise<void> };export function Dns() {  return (    <DnsManagement      zone="example.com"      records={records}      onSave={(input) => api.save("example.com", input)}      onDelete={(id) => api.remove(id)}    />  );}

Server Tools · beta

Live examples and controls: DnsManagement in the lab.

Install

npx shadcn@latest add https://docs.nasaqui.com/r/dns-management.json

The records of one DNS zone. A DataTable with search, a type filter and paging; an add and edit dialog that checks the value against the type; a proxy switch in each row; and a confirmed delete. It does not talk to any DNS provider: your callbacks do, and you pass the updated records back.

When to use

  • A domain settings page for a product that manages customer or own DNS.
  • Anywhere people edit A, AAAA, CNAME, MX, TXT, NS, SRV or CAA records.

When not to use

  • Registering domains or checking ownership: that is a different flow.
  • Editing zone files as text.

Import

import { DnsManagement } from "@fadymondy/nasaq/web";
// inside this monorepo: "@nasaq/web"

Quick start

import { DnsManagement, type DnsRecord } from "@fadymondy/nasaq/web";

declare const records: DnsRecord[];
declare const api: { save(zone: string, input: unknown): Promise<void>; remove(id: string): Promise<void> };

export function Dns() {
  return (
    <DnsManagement
      zone="example.com"
      records={records}
      onSave={(input) => api.save("example.com", input)}
      onDelete={(id) => api.remove(id)}
    />
  );
}

Anatomy

DnsManagement                   data-slot="dns-management"
├─ toolbar                      search, type facet filter, Add record
├─ DataTable                    type, name, content, TTL, proxy, row menu (Edit, Delete)
├─ pagination
├─ record dialog                data-slot="dns-record-form": type, name, content, priority, TTL, proxy, comment
└─ delete AlertDialog

API

DnsManagement: every div prop except children, plus:

PropTypeDefaultDescription
zonestringrequiredThe domain, such as example.com. Names are shown relative to it.
recordsreadonly DnsRecord[]required{ id, type, name, content, ttl, proxied?, priority?, comment? }. TTL is seconds, 1 is Auto.
typesreadonly string[]A, AAAA, CNAME, MX, TXT, NS, SRV, CAATypes offered in the form.
ttlOptionsreadonly number[]Auto, 1 min, 5 min, 15 min, 1 h, 4 h, 1 dayTTL choices.
proxybooleantruefalse hides the proxy column and switch.
loadingbooleanfalseSkeleton rows.
onSave(input: DnsRecordInput) => Promise<void | { error? }>requiredAdd (no id) or edit (with id). { error } shows in the form.
onDelete(id) => Promise<void | { error? }>Shows Delete.
onToggleProxy(id, proxied) => Promise<void | { error? }>Flip the proxy from the table. Optimistic, rolled back on error.
labelsPartial<DnsManagementLabels>Override any string.

Helpers (pure, tested): validateRecord(draft, zone, existing, editingId?), isIPv4, isIPv6, isHostname, isProxiable, needsPriority, relativeName, fqdn, formatTtl.

Examples

Zone without a proxy

import { DnsManagement, type DnsRecord } from "@fadymondy/nasaq/web";

declare const records: DnsRecord[];

export const NoProxy = () => <DnsManagement zone="example.org" records={records} proxy={false} onSave={async () => {}} />;

Accessibility

  • The table is a real <table> with sortable headers. Dialogs trap focus and return it; delete is an AlertDialog.
  • Field errors are tied to the field and announced. The proxy switch has a label.
  • Proxy state is a word ("Proxied", "DNS only"), not colour alone.

RTL & i18n

  • English and Arabic strings follow the Nasaq locale. Names, values, IPs and TTL numbers are dir="ltr".

Styling & tokens

  • Built on DataTable, Dialog, AlertDialog, Switch, Badge and --nq-* tokens.
  • Target [data-slot="dns-management"].

Do / Don't

  • Do validate again on your server. The form only catches typing mistakes.
  • Do return { error } for provider errors so they show next to the form.
  • Don't turn on the proxy for MX, TXT or other types that cannot be proxied. The switch is off for them.
  • Don't hand over a zone with thousands of records without server paging.

Lab

https://docs.nasaqui.com/?path=/docs/components-server-tools-dns-management--docs

On this page