Skip to content

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.

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 session
const me = await client.meOrNull();
if (!me) client.auth.login(location.pathname);
const servers = await client.portal.servers(); // servers with a portal
const 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() (reads cicord_token / cicord_code from 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), or client.routes(plugin, server, instance).call("GET /leaderboard") with the generated route types.
  • Errors are CicordApiError with the API’s error code. Every state-changing call sends the X-Cicord-Request header the runtime requires.

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>;
}

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.

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).

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.