@nukipa/site-sdk
v0.4.0
Published
Typed client for the Nukipa public API — fetch tenant content and ship visit / CTA / form signals from per-tenant sites.
Readme
@nukipa/site-sdk
Typed client for the Nukipa public API (/public/v1/*). Used by tenant
sites under sites/ to fetch content and ship signals back.
import { createNukipaClient } from '@nukipa/site-sdk';
import { headers } from 'next/headers';
const client = createNukipaClient({
gatewayUrl: process.env.NUKIPA_GATEWAY_URL!,
// Resolved per-call. Server components / RSC can read from the request.
getHost: async () => process.env.NUKIPA_TENANT_HOST
|| (await headers()).get('x-forwarded-host')
|| (await headers()).get('host')
|| ''
});
const tenant = await client.getTenant();
const posts = await client.listPosts({ limit: 10 });
await client.recordVisit({ path: '/blog' });Source of truth
The TypeScript types in src/types.gen.ts are generated from the OpenAPI
spec at apps/gateway/openapi.public.yaml.
Update the YAML when you add or change a public endpoint, then regenerate:
npm run codegen -w @nukipa/site-sdkThe runtime wrapper in src/client.ts is hand-maintained — codegen only
touches types.gen.ts. When adding a new operation, you'll edit both:
the spec for the type and the client method that calls it.
Why hand-written runtime?
openapi-fetch would buy us auto-typed methods, but the public surface is
small (~9 ops) and the per-method ergonomics we want (host resolution,
swallowed analytics errors, next.revalidate defaults) are nicer with a
small hand-rolled wrapper. If the surface grows past ~20 endpoints,
revisit.
