Skip to content
DomainKit
Esc
navigateopen⌘Jpreview
On this page

Host lifecycle

Compose connection, plan review, apply, receipt-bound cleanup, and disconnect actions into a host-owned domain row and product lifecycle.

This integration level keeps DomainKit’s controllers and dialogs while your application owns the outer lifecycle row and decides when each action is available.

import { Cleanup, Connection, Provisioning } from "@domainkit/react";

export function DomainActions({ domain, records, receiptId }) {
  const controller = Connection.useController(domain);
  if (controller.state._tag !== "Connected") {
    return <Connection.Status state={controller.state} />;
  }

  return (
    <Connection.Root status="Connected">
      <Cleanup.Flow connection={controller.state} receiptId={receiptId} />
      <Connection.DisconnectDialog
        connection={controller.state}
        controller={controller}
      />
      <Provisioning.Flow
        connection={controller.state}
        records={records}
        showRecords={false}
      />
    </Connection.Root>
  );
}

Installation

npm install @domainkit/react domainkit effect @effect/atom-react react react-dom
pnpm add @domainkit/react domainkit effect @effect/atom-react react react-dom
yarn add @domainkit/react domainkit effect @effect/atom-react react react-dom
bun add @domainkit/react domainkit effect @effect/atom-react react react-dom

Lifecycle ownership

Provisioning and cleanup are separate reviewed operations:

  1. Provisioning.Flow requests an exact create / noop / conflict plan.
  2. The user authorizes that plan’s digest before the host applies it.
  3. The host persists the returned receipt, including partial results.
  4. Cleanup.Flow plans deletion from that receipt and requests separate authorization.

Do not treat disconnecting a provider as cleanup. Your product decides whether cleanup is required, whether a receipt remains valid, and whether a user may remove records.

Product readiness

A completed provider write is not proof that public DNS has propagated. Use Verification and combine its provider/public-DNS observations with your own product readiness policy.

Accessibility

Keep destructive cleanup and disconnect actions distinguishable in text, not color alone. Preserve the confirmation dialogs, loading states, and failure outcomes supplied by the semantic parts.

API reference

Provisioning.Flow

PropType
connectionTransport.Connected

Connected domain attachment used to plan and apply records.

TypeTransport.Connected
onApplied?(result: Applied | Partial) => void

Called after the host returns a complete or partial apply result.

Type(result: Applied | Partial) => void
recordsReadonlyArray<Transport.DnsRecord>

Product-owned DNS requirements included in the immutable plan.

TypeReadonlyArray<Transport.DnsRecord>
showRecords?boolean

Whether the flow renders the records table alongside its review action.

Typeboolean
Defaulttrue
trigger?ReactElement

Optional element rendered as the review trigger.

TypeReactElement

Cleanup.Flow

PropType
connectionTransport.Connected

Connected domain attachment whose applied records may be cleaned up.

TypeTransport.Connected
onCleaned?(result: Cleanup.Completion) => void

Called after the host returns a complete or partial cleanup result.

Type(result: Cleanup.Completion) => void
receiptIdstring

Apply receipt that bounds the records eligible for cleanup.

Typestring
trigger?ReactElement

Optional element rendered as the cleanup review trigger.

TypeReactElement

Connection.DisconnectDialog

PropType
connectionTransport.Connected

Connected domain attachment to disconnect.

TypeTransport.Connected
controllerConnection.Controller

Controller that performs the detach operation.

TypeConnection.Controller
onOpenChange?(open: boolean) => void

Called when the dialog's open state changes.

Type(open: boolean) => void
open?boolean

Controlled open state. Omit it to use the dialog's internal state.

Typeboolean
trigger?ReactElement | null

Optional trigger element. Pass null to render no trigger.

TypeReactElement | null

Read Plans, authorization, and receipts for the lifecycle invariants behind these controls.

Was this page helpful?