@voyantjs/plugin-sanity-cms
v0.20.0
Published
Sanity CMS sync adapter bundle for Voyant.
Readme
@voyantjs/plugin-sanity-cms
Sanity CMS sync adapter bundle for Voyant.
Architecturally, this package is primarily:
- a Sanity sync adapter
- a subscriber bundle that mirrors Voyant module records into Sanity
- an optional packaged bundle when an app wants one installable entrypoint
It subscribes to module events and mirrors documents into a Sanity dataset keyed
by a voyantId field.
Install
pnpm add @voyantjs/plugin-sanity-cmsUsage
import { sanityCmsPlugin } from "@voyantjs/plugin-sanity-cms"
import { createApp } from "@voyantjs/hono"
const sanitySync = sanityCmsPlugin({
projectId: env.SANITY_PROJECT_ID,
dataset: "production",
token: env.SANITY_TOKEN,
documentType: "product",
// optional: apiVersion, voyantIdField, apiHost, events, mapEvent, logger
})
const app = createApp({
plugins: [sanitySync],
})Uses GROQ for reads and Sanity Mutations API for writes. sanityCmsPlugin(...)
is the packaged distribution helper; at runtime the package is primarily a
subscriber-driven Sanity sync adapter. Default apiVersion is "2024-01-01".
By default it wires up 3 subscribers
(product.created, product.updated, product.deleted).
Exports
| Entry | Description |
| --- | --- |
| . | Barrel re-exports |
| ./plugin | sanityCmsPlugin(options) — packaged adapter/subscriber bundle |
| ./client | createSanityClient — upsertByVoyantId, deleteByVoyantId, findByVoyantId |
| ./types | Adapter and bundle option types |
License
Apache-2.0
