function

createClient

Create a typed client from a Ridu base URL and transport options.

Example

ts
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

ArgumentTypeDescription
optionsClientOptions<DefaultAuth>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>

Source packages/sdk/src/index.ts:1

Related types

  • RiduConfigShape

    The minimum generated contract shape consumed by the SDK.

  • AuthCollectionSlug

    Collection slugs with the generated auth capability.

  • ClientOptions

    Transport and middleware options for createClient.

  • RiduClient

    The complete typed REST client for schema, auth, access, content, uploads, versions, globals, preview, and preferences.