Build a site with Site Kit and cms-sdk
Guide
Updated 13/11/2026
The CMS does not draw a front end. A site only reads published content and shows it; you, an agency or an AI tool can build it, and it can be rebuilt at any time because the content stays in the CMS. Site Kit gathers the parts that are hard to get right: a machine-readable content model, sample code for Next.js, Astro and plain JavaScript, and the check command.
Before you start
- A CMS site with at least one public content type and some published entries.
- A store key (
cmspk_…) for that site. An administrator issues it in the Console; see Set up a content site. - To fetch the Site Kit bundle the key needs the
kitfeature; for draft preview it also needspreview.
Steps
-
Export the Site Kit bundle so the build tool has the full context: type schemas, blocks, brand tokens, the “never do” rules and sample code.
Terminal window npx @datazen/cms-site-kit export -
Read content with the Store API. Send the key in the
x-publishable-api-keyheader:Terminal window curl -H "x-publishable-api-key: $CMS_STORE_KEY" "$CMS_URL/store/cms/site"curl -H "x-publishable-api-key: $CMS_STORE_KEY" "$CMS_URL/store/cms/types/article/entries?limit=10"curl -H "x-publishable-api-key: $CMS_STORE_KEY" "$CMS_URL/store/cms/resolve?path=/about"GET /store/cms/sitereturns the site’s languages, time zone andbase_url.GET /store/cms/resolve?path=turns a site path into an entry, a redirect or a 404. Build every page from it; do not guess paths.- The site and type scope come from the key. Do not send
site,site_idorenvin the query: the CMS answers 400. - Send
If-None-Matchwith the ETag you received to get a 304 when nothing changed.
-
Build the sitemap, robots and redirects from
/store/cms/seo/*instead of writing your own. -
Add draft preview, webhook refresh and, if you take enquiries, forms.
-
Run
checkagainst the deployed site:Terminal window npx @datazen/cms-site-kit check https://your-site.example
Read content with cms-sdk
The @datazen/cms-sdk package is a read-only Store API client with types generated from OpenAPI, ETag handling, retries and a stale fallback when the CMS is slow (the stale flag):
import { createStoreClient } from "@datazen/cms-sdk"
const cms = createStoreClient({ baseUrl: process.env.CMS_URL!, key: process.env.CMS_STORE_KEY! })const { data, stale } = await cms.call("storeListEntries", { path: { type: "article" }, query: { limit: 10 } })The SDK has no write operations: submitting forms and opening a preview session are still direct calls, as in those guides.
Reading the check result
- Green means the DataZen side is fine. Red names the exact rule that failed, for example
rule.never.utm. - A check that needs the CMS and could not run is reported as
skipwith a reason, never as a falsepass. - SEO checks (page description, share tags,
robots, redirect map) run with--seo. A site without a CMS uses--no-cms. - Keep the store key on the site’s server or in an environment variable; never in code that runs in the browser (
never.keys-client).
Common errors
401 cms_key_invalid: wrong key, revoked key, missing feature, or Site Kit not enabled on the server. The CMS deliberately returns the same error for every reason.403 cms_origin_forbidden: the key has anoriginslist and the requestOriginis not in it.400 cms_param_unknown: the query has a key the CMS does not accept.- A key limited by type: every response is
private, no-store; do not put it in a shared cache.
See also
- Site Kit and Store API: the full technical docs.
- Site Kit error codes.