Set up Puck Pages
Puck Pages is experimental and may change in a future release.
Add the Pages plugin to browse, create, and save pages from your Puck editor.
Via the CLI
Set up Puck Pages with the CLI:
npx @puckeditor/core add pagesManual setup
The plugin calls puckHandler at /api/puck/pages. Mount it first, as described in Set up Cloud plugins.
Install the plugin
Install the @puckeditor/plugin-pages package:
npm i @puckeditor/plugin-pages --saveLoad the plugin
Add the plugin to <Puck>:
import { createPagesPlugin } from "@puckeditor/plugin-pages";
const pagesPlugin = createPagesPlugin();
export function Editor() {
return (
<Puck
plugins={[pagesPlugin]}
// ...
/>
);
}Get published pages
Get a published version of a page with pages.getPublished().
import puckCloud from "@puckeditor/cloud-client";
const puck = puckCloud();
await puck.pages.getPublished("/"); // { data: { content: [], root: {} } }Render a page
To render a page, provide the page data to <Render>.
import puckCloud from "@puckeditor/cloud-client";
import { Render } from "@puckeditor/core";
import { notFound } from "next/navigation";
import config from "../puck.config";
const puck = puckCloud();
export default async function Page() {
const page = await puck.pages.getPublished("/");
if (!page) notFound(); // The page doesn't exist, or isn't published
return <Render config={config} data={page.data} />;
}