# @repo/cms-client — Dual-Mode Payload Client Provides typed access to Payload CMS via Local API (primary) or HTTP REST (fallback). ## THIS PACKAGE IS STANDALONE - NEVER import from: `@repo/cms-core`, `@repo/core`, `apps/*` - The Payload instance is INJECTED, not imported - Types are generated via `payload generate:types` ## Initialization | Context | Mode | How | |---|---|---| | apps/cms server | Local | `getPayload({config})` from @repo/cms-core | | apps/web-next server | Local | `getPayload({config})` from @repo/cms-core | | apps/web-tanstack server | Local | `getPayload({config})` from @repo/cms-core | | Client-side (browser) | N/A | Goes through tRPC — server handles it | | External services | HTTP | `createPayloadClient({mode:"http",baseURL})` | ```typescript // In app startup (e.g., apps/web-next/src/lib/payload.ts): import { getPayload } from "payload"; import { config } from "@repo/cms-core"; import { createPayloadClient } from "@repo/cms-client"; const payload = await getPayload({ config }); const client = createPayloadClient({ mode: "local", payload }); ``` ## Available Methods All methods support full Payload query capabilities (where, sort, limit, depth, page, populate): - `find(collection, options)` — paginated query - `findByID(collection, id, options)` — single document - `create(collection, data, options)` — create document - `update(collection, id, data, options)` — update document - `delete(collection, id)` — delete document