Build on PageHub

Let an agent build and publish a site, read your content as JSON, serve a PageHub site from your Next.js app, or put the visual editor in your own app. One site format, five ways in.

MCP server

Connect Claude, Cursor, or any MCP client to https://pagehub.dev/api/mcp. Your agent builds in a draft, checks its work with screenshots and audits, and publishes when you say so. You sign in through the browser, so there's no key to copy.

terminal
claude mcp add --transport http PageHub https://pagehub.dev/api/mcp

REST API

Everything the editor does is under /api/v1: sites, a site's HTML and Liquid files, media, collections, releases. Create an API key in your dashboard and send it as a Bearer token. File writes are saved atomically, and a stale write comes back as a version conflict instead of overwriting someone's edit.

curl
# Your sites
curl -H "Authorization: Bearer ph_your_key" \
  https://pagehub.dev/api/v1/sites

# Every file in a site's draft: { paths, versions, version }
curl -H "Authorization: Bearer ph_your_key" \
  https://pagehub.dev/api/v1/sites/SITE_ID/files

# Create or change one file. baseVersion: null means "must not exist yet".
curl -X PUT \
  -H "Authorization: Bearer ph_your_key" \
  -H "Content-Type: application/json" \
  -d '{ "text": "<section>…</section>", "baseVersion": null }' \
  https://pagehub.dev/api/v1/sites/SITE_ID/files/pages/about.liquid

# Go live
curl -X PUT \
  -H "Authorization: Bearer ph_your_key" \
  -H "Content-Type: application/json" \
  -d '{ "published": true }' \
  https://pagehub.dev/api/v1/sites/SITE_ID

Content API

Use PageHub as a headless CMS. Every collection is a JSON endpoint with search, sort, filters and pagination. Public collections read without a key. Private ones need an API key. A typed client comes from the OpenAPI file at /api/v1/content/openapi.json.

fetch
// app/blog/page.tsx — any framework, any host
const res = await fetch(
  "https://pagehub.dev/api/v1/content/SITE_ID/posts?limit=10&sort=newest"
);
const { data, meta } = await res.json();
// data: [{ id, title, slug, image, metadata: { … } }]
// meta: { page, limit, count, totalCount, totalPages, hasMore }

Next.js mount

Serve a PageHub site at the root of your Next.js app. Any path your app has no page for falls through to PageHub, including /. Marketing edits the site and publishes, with no app deploy. Move pages over one at a time by deleting the app's version. Install @pagehub/next from npm, turn on static publishing for the site, and set its mount origin to your app's address.

next.config.js
// npm i @pagehub/next
// next.config.js
const { withPageHub } = require("@pagehub/next");

module.exports = withPageHub(config, { site: "your-site-name" });

Embed the editor

The visual editor PageHub runs on is @pagehub/editor, an MIT-licensed React component. Give it a storage adapter for your HTML and Liquid files and your app gets drag and drop, inline text editing, a code view, layers, a theme panel and a client mode that only changes text and images. Every panel can be replaced or hidden, and edits change only the lines they touch, so the files stay yours.

editor.tsx
// npm i @pagehub/editor @pagehub/engine
import { Editor } from "@pagehub/editor";
import "@pagehub/editor/styles.css";

<Editor storage={storage} canvasHost={{ siteCss }} />;

HTML + Liquid format

A site is plain HTML and Liquid files. The reference lists every tag, filter, data object, runtime attribute and lint rule, generated from the renderer so it matches what publishes. Agents read the same text through the MCP get_style_reference tool.

terminal
curl https://pagehub.dev/api/v1/format/liquid

The SDK

@pagehub/sdk is the MIT-licensed code PageHub's own dashboard is built on. Read it, copy from it, or build on it.

What's in it

  • compile-css: Tailwind and DaisyUI compiled for the classes a page uses
  • theme.css and chrome.css: design tokens and dashboard styles
  • email-renderer: CSS values an email client keeps, and HTML to plain text
  • page-settings/fields: the page-settings field contract
  • Modal and confirm dialogs, popovers and the media library UI
compile-css
// npm i @pagehub/sdk
import { compileCSS } from "@pagehub/sdk/compile-css";

// Tailwind + DaisyUI, compiled for just the classes a page uses.
const css = await compileCSS({ classes, themeCSS });