@ion-design/cms-next
v0.1.2
Published
Next.js cache, preview, rendering, and revalidation helpers for Ion CMS
Readme
@ion-design/cms-next
Next.js helpers for Ion CMS published reads, preview sessions, safe Markdown rendering, cache tags, and signed on-demand revalidation.
import { createIonNextCMS } from '@ion-design/cms-next';
export const cms = createIonNextCMS({
projectId: process.env.ION_CMS_PROJECT_ID!,
publicKey: process.env.ION_CMS_PUBLIC_KEY!,
fallbackRevalidate: 3600,
});Create the revalidation route with createIonRevalidationHandler, and use
createIonPreviewExchangeHandler in a server route to exchange Ion's one-time preview code for an
HTTP-only cookie. Preview credentials are never accepted by the published client.
The setup health route is deliberately small and contains no secret:
import { createIonCmsHealthHandler } from '@ion-design/cms-next';
export const GET = createIonCmsHealthHandler({
projectId: process.env.ION_CMS_PROJECT_ID!,
});The published wrapper attaches precise project, collection, entry, and route cache tags and uses a
configurable ISR fallback. Preview uses cache: 'no-store' and a separate client:
import { readIonPreviewStateFromRequest } from '@ion-design/cms-next';
const preview = readIonPreviewStateFromRequest({
request,
projectId: process.env.ION_CMS_PROJECT_ID!,
});Import IonCmsPreviewRefresh from @ion-design/cms-next/preview-refresh and add it only at the CMS page
boundary. Pass it the server-provided editor origin and channel nonce; never pass the preview token
to a Client Component.
IonContent renders portable Markdown and accepts an explicit component map. It rejects imports,
exports, JavaScript expressions, scripts, and event handlers before rendering. Customer-owned
renderers may be used instead.
