|

OpenCoreDev Releases Domain SDK 0.2.0: One TypeScript API to Add, Verify, and Remove Customer Domains Across Five Platforms

Custom domains are a regular SaaS function. Yet each internet hosting platform exposes a distinct API for them. OpenCoreDev has revealed Domain SDK, a TypeScript consumer that normalizes that work. Version 0.2.0 reached npm a day after the primary launch.

What is Domain SDK?

Domain SDK covers Vercel, Cloudflare for SaaS, Railway, Render, and Netlify. You add a hostname, present the precise DNS data, then monitor supplier state till it’s prepared.

It doesn’t register domains, host DNS, deploy apps, proxy visitors, or retailer tenant knowledge. Your utility retains tenant authorization and state. The supplier stays the supply of reality.

The bundle is server-side solely, so credentials by no means attain browser code. engines.node is >=20, and Bun is supported. It is ESM-only and ships one runtime dependency, tldts.

The consumer floor

Within that scope, the API is small. createDomainConsumer() returns a stateless consumer with seven members: add, get, refresh, checklist, confirm, take away, and waitUntilActive. Every methodology accepts an AbortSignal. Add and take away are idempotent, so retries are secure.

Each adapter is a separate entry level: ./vercel, ./cloudflare, ./railway, ./render, ./netlify, and ./testing. Changing platforms means altering the import, not the workflow.

Status is a union, not a boolean

Because DNS, possession, and TLS end at completely different instances, the SDK fashions them individually. DomainStatus carries eight values:

pending, pending_dns, pending_verification, pending_certificate, lively, misconfigured, failed, unknown.

A Domain additionally holds verification (pending | verified | failed | unknown), certificates (pending | lively | expiring | failed | unknown), and an points array. Each problem has a code, message, optionally available report, and a retryable flag.

Records are typed the identical approach. DnsRecord has sort, title, worth, optionally available ttl, function, required, standing, and optionally available description. function is routing, possession, certificates, or different. standing is pending, legitimate, invalid, or unknown.

Consequently, a Vercel hostname surfaces three separate data:

Type Name Purpose
CNAME app.buyer.com routing
TXT _vercel.app.buyer.com possession
TXT _acme-challenge.app.buyer.com certificates

Provider compatibility

While the lifecycle is normalized, platform limits usually are not:

Capability Vercel Cloudflare SaaS Railway Render Netlify
List domains
Explicit verification
Managed certificates
Apex domains
Wildcard domains
Automatic buyer DNS

Cloudflare for SaaS requires a CNAME goal, so the adapter doesn’t declare apex help. Render alone accepts wildcard hostnames. No adapter edits buyer DNS mechanically.

Rather than hard-coding these limits, learn consumer.capabilities at runtime. It exposes checklist, explicitVerification, managedCertificates, apexDomains, and wildcardDomains.

Working with the consumer

The following snippet type-checks and runs towards 0.2.0:

import { createDomainConsumer } from "@opencoredev/domain-sdk";
import { vercel } from "@opencoredev/domain-sdk/vercel";

export const domains = createDomainConsumer({
  supplier: vercel({
    token: course of.env.VERCEL_TOKEN!,
    projectId: course of.env.VERCEL_PROJECT_ID!,
  }),
});

const area = await domains.add("app.buyer.com");

// Render each required report in your customer-facing DNS directions.
const required = area.data.filter((merchandise) => merchandise.required);

const lively = await domains.waitUntilActive(area.hostname, {
  timeoutMs: 300_000,          // default
  intervalMs: 5_000,           // default, minimal 250
  onStatus: (present) => console.log(present.standing),
});

console.log(lively.certificates.standing, lively.verification.standing);

Polling is sequential. It defaults to a 300,000 ms timeout and a 5,000 ms interval. Intervals under 250 ms are rejected, and every state is reported by way of onStatus. When a supplier returns retryAfter, the consumer waits at the very least that lengthy earlier than retrying.

Testing and agent help

For CI, an in-memory adapter by no means calls an actual supplier:

import { createDomainConsumer } from "@opencoredev/domain-sdk";
import { reminiscenceProvider } from "@opencoredev/domain-sdk/testing";

const reminiscence = reminiscenceProvider();
const domains = createDomainConsumer({ supplier: reminiscence });

await domains.add("app.buyer.com");   // standing: pending_dns
reminiscence.activate("app.buyer.com");

const newest = await domains.refresh("app.buyer.com");
console.log(newest.standing === "lively"); // true

It additionally helps transition(), injected latencyMs, per-operation failures, and a calls log. createMockDomain, createMockDnsRecord, and createFailingProvider sit alongside it.

Separately, an agent ability installs the workflow into Codex, Claude Code, Cursor, and different appropriate brokers:

npx abilities add opencoredev/domain-sdk --skill domain-sdk

Use circumstances

  • Multi-tenant SaaS on Vercel: A buyer maps app.buyer.com. Your settings web page renders required CNAME and TXT data with stay standing.
  • Cloudflare for SaaS at scale: Custom Hostnames stay inside one zone. The adapter retains that scoping specific.
  • Tenant subdomains you personal: createSubdomainClient maps labels underneath a base area. reservedLabels blocks www, api, and admin.
  • Provider migration: Swap the adapter import and preserve the identical lifecycle calls.

Interactive Explainer

Key Takeaways

  • Domain SDK normalizes the custom-domain lifecycle throughout 5 platforms behind one TypeScript consumer.
  • DomainStatus has eight values, with separate verification, certificates, and problem fields.
  • Capabilities differ by platform; learn consumer.capabilities as a substitute of hard-coding limits.
  • Idempotent add and take away, AbortSignal help, and fourteen typed error codes make retries secure.
  • At 0.2.0 the API is younger, and its varieties want moduleResolution: "bundler" as of now.


Check out the GitHub RepoAlso, be happy to comply with us on Twitter and don’t neglect to be part of our 150k+ML SubReddit and Subscribe to our Newsletter. Wait! are you on telegram? now you can join us on telegram as well.

Need to companion with us for selling your GitHub Repo OR Hugging Face Page OR Product Release OR Webinar and so forth.? Connect with us

The submit OpenCoreDev Releases Domain SDK 0.2.0: One TypeScript API to Add, Verify, and Remove Customer Domains Across Five Platforms appeared first on MarkTechPost.

Similar Posts