@uidu/client
v3.4.1
Published
Typed GraphQL client for the uidu platform. Server-first, framework-agnostic.
Readme
@uidu/client
Typed, server-first, framework-agnostic GraphQL client for the uidu platform. Runs anywhere — Node, Bun, Deno, or the browser. No React dependency.
Alpha: this is the v3 rewrite of the uidu SDK. It replaces
@uidu/api(v2). APIs may change before the stable release.
Install
npm install @uidu/clientThe package is fully tree-shakable ("sideEffects": false) — only the functions you import end up in your bundle.
Usage
import { createClient, getPage, listEvents } from '@uidu/client';
const client = createClient({
workspace: 'your-workspace', // → https://your-workspace.uidu.org/graphql
publicToken: process.env.UIDU_PUBLIC_TOKEN!,
});
const page = await getPage(client, { projectId: 'proj_xyz', slug: 'home' });
const events = await listEvents(client, { first: 20 });Every domain function follows the same shape: pass the client first, arguments second, get a typed response back.
Use paginate() to walk a connection across pages: paginate((cursor) => listPages(client, { first: 50, after: cursor })).
createClient options
| Option | Required | Description |
|---|---|---|
| workspace | yes | Your workspace subdomain. Resolves to https://{workspace}.uidu.org/graphql. |
| publicToken | recommended | Public read token from your workspace settings. Safe to expose. |
| apiKey | optional | Server-only API key for mutations and private data. Never ship to the browser. |
| endpoint | optional | Override the GraphQL endpoint entirely. |
| headers | optional | Extra request headers to attach to every call. |
What's available
CMS (getPage, listPages, getTemplate), Forms (getForm, listForms, createFormResponse, updateFormResponse), Help Center (getChannel), Search (search), Events (getEvent, listEvents, createAttendance), Calls (getCall, listCalls), Donations (getDonationCampaign, listDonationCampaigns, createDonation), Stories (getStory, listStories), People (listEmployees, getEmployee, weekStartFor), Bookings (getBooking, listBookings, getCalendar, listCalendars, getCalendarEvent, listCalendarEvents), Courses (getCourse, listCourses, getEnrollment, listEnrollments, getLecture, listLectures), Campaigns (getCampaign, listCampaigns, listEmailCampaigns), Contacts (getContact, listContacts, getDeal, listDeals), and KB (getKbArticle, listKbArticles, getKbCollection, listKbCollections).
Docs
Full per-app reference and cookbook recipes: apps/website/content/docs in this repo.
For React apps, see @uidu/react.
License
MIT © uidu
