Domain SDK

Installation

Install Domain SDK and start managing customer domains from your server.

1. Install the package

Terminal
bun add @opencoredev/domain-sdk

Domain SDK is server-only. Keep it in API routes, server actions, workers, or another trusted backend.

Install the agent skill

Give Codex, Claude Code, Cursor, and other compatible coding agents the Domain SDK workflow and safety rules:

Terminal
npx skills add opencoredev/domain-sdk --skill domain-sdk

The skills CLI asks which detected agents should receive the skill. Add -g to make it available across all of your projects.

2. Choose your provider

Use the platform that currently receives traffic for your application. Each adapter is a separate import and uses credentials scoped to one project, service, site, or zone.

3. Create the client

Put the client in a server-only module. Pick the tab that matches your provider; its provider page lists the required credentials and platform-specific behavior.

src/server/domains.ts
import { createDomainClient } from "@opencoredev/domain-sdk";
import { vercel } from "@opencoredev/domain-sdk/vercel";

export const domains = createDomainClient({
  provider: vercel({
    token: process.env.VERCEL_TOKEN!,
    projectId: process.env.VERCEL_PROJECT_ID!,
  }),
});

Never expose provider credentials through NEXT_PUBLIC_, VITE_, or another browser-accessible environment variable.

4. Add and refresh a domain

src/server/customer-domain.ts
import { domains } from "./domains";

const domain = await domains.add("app.customer.com");

// Show every required record in your customer-facing DNS instructions.
const requiredRecords = domain.records.filter((record) => record.required);

const latest = await domains.refresh(domain.hostname);
if (latest.status === "active") {
  // The configured provider now reports the domain as ready.
}

Store the hostname's tenant ownership in your own database. Domain SDK is stateless and the configured provider remains the source of truth for readiness.

Read next: Compare providers.