dynamic-zone
v1.0.8
Published
Dynamic zone scaffolding for Next.js apps
Downloads
649
Maintainers
Readme
dynamic-zone
Scaffold a CMS dynamic zone for Next.js apps. Zero dependencies, zero config.
Requirements
- Next.js (App Router)
- An
appdirectory in your project
Installation
npm install dynamic-zone
# or
pnpm add dynamic-zone
# or
yarn add dynamic-zoneUsage
Run from your Next.js project root:
npx dynamic-zoneOr if installed globally:
dynamic-zoneWhat It Creates
app/
└── cms/
├── components/ # Add your section components here
└── dynamic-zone/
└── section-renderer.tsxNext Steps
Add section components to
app/cms/components/(e.g.hero.tsx,features.tsx).Register them in the
componentMapinsection-renderer.tsx:
const componentMap: { [key: string]: ComponentMapType } = {
hero: dynamicImport("hero"),
features: dynamicImport("features"),
};- Use the renderer in your pages:
import SectionRenderer from "@/app/cms/dynamic-zone/section-renderer";
export default function Page({ page }) {
return <SectionRenderer sections={page.sections} slug={page.slug} />;
}The __component field from your CMS (e.g. sections.hero) is parsed to match the component key (hero → hero).
CLI Options
| Flag | Description |
| --------------- | ------------ |
| -h, --help | Show help |
| -v, --version | Show version |
License
ISC
