@ieportals/vercel-dns-provider
v1.0.1
Published
A tiny TypeScript helper for adding/removing Vercel project domains and reading domain config.
Downloads
1,002
Readme
vercel-dns-provider
A tiny TypeScript helper for adding/removing Vercel project domains and reading domain config.
Environment variables
An example env file is included at .env.example.
Runtime keys:
VERCEL_API_BASEVERCEL_BEARER_TOKENVERCEL_PROJECT_IDVERCEL_BASE_DOMAIN
Optional test keys:
VERCEL_TEST_BASE_DOMAIN
Usage
import { createVercelClient } from "@ieportals/vercel-dns-provider";
const dns = createVercelClient({
baseUrl: process.env.VERCEL_API_BASE || "https://api.vercel.com",
bearerToken: process.env.VERCEL_BEARER_TOKEN || "",
projectId: process.env.VERCEL_PROJECT_ID || "",
baseDomain: process.env.VERCEL_BASE_DOMAIN || "example.com",
});
const addResult = await dns.addSubdomain("staging");
if (!addResult.success) {
console.error("Add failed:", addResult.error);
}
const removeResult = await dns.removeSubdomain("staging");
if (!removeResult.success) {
console.error("Remove failed:", removeResult.error);
}API
createVercelClient(config)
Creates a client with shared config and returns methods:
addSubdomain(subdomain: string)removeSubdomain(subdomain: string)addCustomDomain(domain: string)removeCustomDomain(domain: string)getDomainConfig(domain: string)
Config fields:
baseUrl- Vercel API base URLbearerToken- Vercel bearer tokenprojectId- Vercel project idbaseDomain- Base domain for generated subdomains (for exampleexample.com)
Testing
Run tests:
pnpm testVitest loads .env and .env.local automatically for tests.
Integration tests always run. If required env vars are missing, tests fail with a clear error.
VERCEL_BEARER_TOKENis setVERCEL_PROJECT_IDis setVERCEL_TEST_BASE_DOMAINis set
