Multi-site admin
One admin and one sign-in over every client site, with the proposals waiting in all of them in one place. For the Agency plan.
On the Agency plan, a hub manages many sites from one place. Each site is a repository with its own content, settings, proposals and media, so a client who leaves takes a whole site with them. The hub reads each repository’s schema, serves that site’s full admin at its own address, and gives you a home page that lists every site and what is waiting for review in each.
A site opened through the hub is the same admin you already know: the editor, reviews, media, the agent, roles. Each site keeps its own agent settings and instructions in its own .prime folder.
Set up a site
Each site commits its schema, so the hub can read it without running the site’s code. In the site’s project:
bunx @getprimecms/cli schema # writes .prime/schema.json
git add .prime/schema.json && git commit -m "Add the prime schema"
Run primecms schema again whenever you change the collections or fields. In CI, primecms schema --check fails when the file is missing or out of date, so it never drifts. A site whose file is missing or invalid shows why on the hub’s home page, and the other sites are not affected.
The hub changes content through the GitHub API, so sites use GitHub storage. Create a fine-grained token for each repository with Contents read and write on that repository only.
Run the hub
Create prime.hub.ts in a project of its own:
import { basicAuth, defineHub } from "@getprimecms/server";
export default defineHub({
name: "Northwind Agency",
license: process.env.PRIME_LICENSE,
auth: basicAuth({
users: [
{ username: "ada", password: process.env.ADA_PASSWORD!, role: "admin" },
{ username: "wren", password: process.env.WREN_PASSWORD!, role: "writer" },
],
}),
sites: [
{ id: "acme", repo: "northwind/acme-site", token: process.env.ACME_TOKEN! },
{ id: "globex", name: "Globex", repo: "northwind/globex-site", token: process.env.GLOBEX_TOKEN! },
],
});
bunx @getprimecms/cli hub --host 0.0.0.0 --port 4300
The hub is a plain fetch handler, so you can also run it yourself: createHub(options).fetch takes a Request and returns a Response, which fits a Cloudflare Worker, Bun or any Node server.
Keep tokens and passwords in environment variables, never in the file. auth is required in production: without it the hub is closed outside local development, like a site’s admin. The license is your Agency key, checked as requests arrive and remembered for ten minutes.
What you see
The hub’s home lists every site with the proposals waiting in it, and a single list of everything waiting across all of them, newest first. A proposal opens in its own site’s Reviews. Inside a site, the header shows which site you are in and lets you move to another or back to all of them.
You see only the proposals your role allows. Each site is asked on your behalf, so roles and collection limits apply exactly as they do inside that site. The list is reused for twenty seconds, so a count can lag a moment behind a change.
Roles across sites
One sign-in covers the hub and every site. Roles come from your auth handler and the hub’s access setting, as described in Access and roles, and a site can set its own with access on that site:
sites: [
{ id: "acme", repo: "northwind/acme-site", token: process.env.ACME_TOKEN!, access: { users: { "client@acme.com": "editor" } } },
],
Everyone who can sign in to the hub can open every site, with the role they hold there. Hiding some sites from some people is not built yet.
What it needs
The Agency plan, with one license for the whole hub. A site’s repository needs .prime/schema.json and a token. Content, proposals, settings and media all live in the site’s repository, so nothing about a client is stored in the hub.