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 editor and its parts in your own app. Every site is plain HTML and Liquid files.

https://pagehub.dev/api/mcp

MCP server

Connect Claude, Cursor or any MCP client. You sign in through the browser, so there's no key to copy.

  • Builds in a draft, never on your live site
  • Checks its own work with screenshots and audits
  • Publishes only when you say so
terminal
claude mcp add --transport http PageHub https://pagehub.dev/api/mcp
/api/v1

REST API

Everything the editor does is under /api/v1. Create an API key in your dashboard and send it as a Bearer token.

  • Sites, HTML and Liquid files, media, collections and releases
  • Each file write is saved whole or not at all
  • 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 one file (baseVersion: null = 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
/api/v1/content

Content API

Use PageHub as a headless CMS. Every collection is a JSON endpoint.

  • Search, sort, filters and pagination
  • Public collections read without a key, private ones need one
  • A typed client from /api/v1/content/openapi.json
fetch
// 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 }
@pagehub/next

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 and publishes with no app deploy
  • Move pages over one at a time by deleting the app's version
  • Setup: 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" });
@pagehub/editor

Embed the editor

The visual editor PageHub runs on, as an MIT-licensed React component. Give it a storage adapter for your HTML and Liquid files.

  • Drag and drop, inline text editing, a code view, layers and a theme panel
  • A client mode that only changes text and images
  • Every panel can be replaced or hidden
  • 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 }} />;
@pagehub/sdk

The SDK

The MIT-licensed code PageHub's own dashboard is built on. Read it, copy from it, or build on it.

  • compile-css: Tailwind and DaisyUI, compiled for the classes a page uses
  • email-renderer: CSS an email client keeps, and HTML to plain text
  • theme.css and chrome.css: design tokens and dashboard styles
  • chrome/*: the modal, confirm dialog and popover hooks
  • utils/*: icon resolution and the media upload pipeline
sdk.ts
// npm i @pagehub/sdk
import { compileCSS } from "@pagehub/sdk/compile-css";
import { htmlToText } from "@pagehub/sdk/email-renderer";

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

// The plain-text part of an email
const text = htmlToText(html);
/docs/schema

HTML + Liquid format

A site is plain HTML and Liquid files. One reference covers all of it.

  • 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