Skip to Content
ClientOptions

Client options

Every CMS adapter’s client factory (e.g. createStatamicClient) takes the same options:

import { } from "@headquery/statamic"; import type { Schema } from "./cms.generated"; export const = <Schema>({ : "https://cms.example.com", : { : "force-cache" }, });
OptionDefaultDescription
baseUrl—Origin of the CMS, e.g. https://cms.example.com
apiPrefix/apiPath of the CMS’s REST API (for Statamic: statamic.api.route)
token—Sent as Authorization: Bearer <token>
headers—Extra headers for every request
fetchglobalThis.fetchCustom fetch (SSR frameworks, tests, polyfills)
fetchOptions—Merged into every fetch call, e.g. { cache: "force-cache" } or Next’s { next: { revalidate: 60 } }

Per call

.get({ signal, fetchOptions }) accepts an AbortSignal and fetch options that override the client’s:

const = new (); await .("settings").({ : ., : { : "no-store" } });

Where the client file comes from

headquery init writes a client file (src/cms.ts) that passes the generated Schema and reads baseUrl from env. Import cms from it wherever you query. Why the Schema generic is there is explained under Types.

Last updated on