function
createClient
Create a typed client from a Ridu base URL and transport options.
Example
import "~/generated/ridu.generated";
import { createClient } from "@riducms/sdk";
const cms = createClient({ baseURL: "https://cms.example.com" });
const posts = await cms.list("posts", {
limit: 20,
sort: ["-publishedAt"],
});Arguments
| Argument | Type | Description |
|---|---|---|
options | ClientOptions< | Base URL and optional Fetch, headers, credentials, and middleware. |
Returns
A client whose slugs and payloads come from Config.
RiduClient<Config, DefaultAuth>How it works
Import the generated client module once to register its config, or pass its config type explicitly when a TypeScript program contains multiple Ridu applications.
Methods return ordinary Promise values. Non-2xx responses and malformed success envelopes reject with RiduError.
Full signature
function createClient<
Config extends RiduConfigShape = RiduConfigShape,
const DefaultAuth extends AuthCollectionSlug<Config> = never,
>(options: ClientOptions<DefaultAuth>): RiduClient<Config, DefaultAuth>Related types
RiduConfigShapeThe minimum generated contract shape consumed by the SDK.
AuthCollectionSlugCollection slugs with the generated auth capability.
ClientOptionsTransport and middleware options for createClient.
RiduClientThe complete typed REST client for schema, auth, access, content, uploads, versions, globals, preview, and preferences.