@blockforgecms/cms-react
v0.1.2
Published
Embedded React admin runtime for BlockForge (self-contained, no root `App.tsx` dependency).
Readme
@blockforgecms/cms-react
Embedded React admin runtime for BlockForge (self-contained, no root App.tsx dependency).
Exports:
BlockforgeAdmincreateBlockforgeAppCustomBlockRendererPropsCustomBlockRenderers
Usage:
'use client';
import dynamic from 'next/dynamic';
import '@blockforgecms/cms-react/styles.css';
const BlockforgeAdmin = dynamic(
() => import('@blockforgecms/cms-react').then((mod) => mod.BlockforgeAdmin),
{ ssr: false },
);Add Custom Components
- Create a typed content contract in your host app under
components/blocks/*.tsx, for example:
export type TestimonialsBlockContent = {
title: string;
items: { quote: string; author: string }[];
};- Generate contracts:
npm run cms-model:scan- Make sure
content-models.generated.jsonis served at/content-models.generated.json(typically from host app/public). - Register a renderer on
BlockforgeAdmin:
import type { CustomBlockRendererProps } from '@blockforgecms/cms-react';
const TestimonialsBlock = ({ content }: CustomBlockRendererProps<{
title: string;
items: { quote: string; author: string }[];
}>) => (
<section>
<h2>{content.title}</h2>
{content.items.map((item, index) => (
<blockquote key={index}>
{item.quote} — {item.author}
</blockquote>
))}
</section>
);
<BlockforgeAdmin
customRenderers={{
TESTIMONIALS: TestimonialsBlock,
}}
/>;Keys are matched by normalized model key (for example ImageGallery => IMAGE-GALLERY).
