@subdomainto/nuxt
v0.1.1
Published
Server-only Nuxt and Nitro helpers for the subdomain.to custom domains API, runtime configuration, and signed H3 webhooks.
Maintainers
Readme
subdomain.to for Nuxt and Nitro
@subdomainto/nuxt provides server-only Nuxt, Nitro, and H3 helpers for adding customer custom domains to a SaaS application. It creates the typed subdomain.to API client from server environment variables and verifies signed H3 webhook events.
Installation
npm install @subdomainto/nuxtThe package supports Nuxt 3 and 4 with H3 1.15 or 2.x. Keep every API key and webhook secret out of public runtime configuration.
Create the API client
import { createSubdomainToClient } from '@subdomainto/nuxt';
const client = createSubdomainToClient();
const domain = await client.domains.create(
'portal.customer.com',
'customer-42-domain',
);The helper reads SUBDOMAINTO_API_KEY and optional SUBDOMAINTO_BASE_URL. Use it in Nitro handlers, server routes, plugins that run only on the server, or other trusted server code.
Verify an H3 webhook
import { verifyWebhookEvent } from '@subdomainto/nuxt';
export default defineEventHandler(async (event) => {
const webhook = await verifyWebhookEvent(event);
return { received: webhook.id };
});verifyWebhookEvent() reads the untouched H3 body, SubdomainTo-Signature, and SUBDOMAINTO_WEBHOOK_SECRET. It verifies the HMAC signature and timestamp before returning the typed event.
Documentation
Read the Nuxt SDK guide, browse the custom domains API documentation, or report an issue in the JavaScript SDK repository.
License
MIT
