SDK packages
The portal SDK is a set of layered packages. Use only @cicord/client from a plain web page, add
@cicord/react in a React app, and @cicord/ui if you want the themed components of the reference
portal. All of them are Apache-2.0.
@cicord/client
Section titled “@cicord/client”A typed, framework-agnostic client of the runtime’s HTTP API (see the HTTP API reference).
import { createCicordClient } from "@cicord/client";
const client = createCicordClient(); // same origin, cookie sessionconst me = await client.meOrNull();if (!me) client.auth.login(location.pathname);const servers = await client.portal.servers(); // servers with a portalconst profile = await client.portal.me(servers[0].key); // the viewer's member and roles- Auth:
auth.login(),auth.loginUrl(),auth.link(token)(portal links),auth.exchangeLinkToken()(readscicord_token/cicord_codefrom the URL),auth.redeem(),auth.devLogin()(dev mode),auth.logout(). Cookie mode by default;auth: "token"for token mode. - Portal:
portal.servers(),portal.server(key),portal.me(key). - Plugin routes:
client.plugin(server, bot, instance).get("/leaderboard")(untyped), orclient.routes(plugin, server, instance).call("GET /leaderboard")with the generated route types. - Errors are
CicordApiErrorwith the API’s errorcode. Every state-changing call sends theX-Cicord-Requestheader the runtime requires.
@cicord/react
Section titled “@cicord/react”A provider, data hooks and headless components for React 19.
| Export | Purpose |
|---|---|
<CicordProvider> |
Holds the client, the query cache and the session. |
useMe, useSession, useLogout, useLinkTokenLogin |
The viewer and their session. |
usePortalServers, usePortalServer, useServerKey |
Servers and their PortalServer options. |
useMember, useRoles |
The viewer’s member and roles on a server. |
usePortalPlugin, usePluginQuery, usePluginMutation |
Plugin routes, untyped. |
useRouteQuery, useRouteMutation |
Plugin routes, typed from route contracts. |
<OnboardingFlow>, useOnboarding |
A headless onboarding flow on top of the onboarding plugin. |
import { useRouteQuery } from "@cicord/react";
function Leaderboard() { const board = useRouteQuery("levels", "GET /leaderboard", { query: { limit: 10 } }); if (!board.data) return null; return <ol>{board.data.items.map((m) => <li key={m.userId}>{m.displayName}</li>)}</ol>;}@cicord/ui
Section titled “@cicord/ui”Optional styled components driven by the server’s theme (spec.portal.theme):
ThemeProvider (derives every color from primary and accent), MemberCard, RoleChip,
Avatar, Button, LinkButton, Card, Notice, Stepper, ChoiceGroup, ProgressBar,
Spinner, Markdown (the safe Markdown subset of spec.portal.description) and LinkIcon.
create-cicord-portal
Section titled “create-cicord-portal”The reference portal served at / by default: a complete showcase of the SDK (every portal
endpoint, cookie and token auth, profile, onboarding, leaderboard, tickets, a developers page,
English and French). It is not published as a package; fork it with cicord portal init (see
Custom portal).
@cicord/sdk
Section titled “@cicord/sdk”Not a portal package, but part of the same family: the plugin authoring API
(definePlugin, command, defineRoutes) and @cicord/sdk/testing. See
Writing a plugin.