Sanity
Use Sanity when document types expose slug fields and can be queried through the HTTP Query API.
Install
For CLI scans, @cms-lab/cli includes the bundled adapter. Add @cms-lab/core for defineConfig. Install @cms-lab/sanity only when importing the adapter directly in project code or tests.
pnpm add -D @cms-lab/cli @cms-lab/core pnpm add -D @cms-lab/sanity
Config
import { defineConfig } from "@cms-lab/core";
export default defineConfig({
site: { url: "http://localhost:3000" },
framework: { type: "next", router: "app" },
cms: {
provider: "sanity",
projectId: "my-project",
dataset: "production",
apiVersion: "2025-02-19",
token: process.env.SANITY_READ_TOKEN,
contentTypes: [
{ type: "page", documentType: "page", uidField: "slug.current" },
{ type: "article", documentType: "post", uidField: "slug.current" },
],
},
routes: [
{ type: "page", pattern: "/:slug", getPath: (doc) => "/" + doc.uid },
{ type: "article", pattern: "/blog/:slug", getPath: (doc) => "/blog/" + doc.uid },
],
});UID and URL field mapping
Use uidField when the route key lives in a custom nested CMS field. Use urlField when the CMS stores the public permalink. Both read dotted paths from document.data.
cms: {
provider: "sanity",
contentTypes: [
{
type: "article",
documentType: "post",
uidField: "slug.current",
urlField: "seo.canonical",
},
],
}CI command
npx @cms-lab/cli doctor npx @cms-lab/cli scan --ci --report --fail-on error
Provider caveats
- cms-lab runs one query per configured document type.
- The perspective defaults to published unless configured otherwise.
- Custom GROQ projections and reference expansion are not built in yet.
Check the adapter maturity matrix before using this provider as a strict deploy gate.