Deploying
Run the admin in production with real authentication and storage that fits your host.
Locally, prime is open on localhost and closed everywhere else. A production build refuses every request until you choose who may use the admin.
Authentication
import { basicAuth } from "@getprimecms/server";
export default defineConfig({
auth: basicAuth({
username: process.env.PRIME_USER!,
password: process.env.PRIME_PASSWORD!,
}),
});
In production the password must be at least 16 characters (make one with openssl rand -base64 24), and the admin only opens over HTTPS. Until both are true it stays closed and says why. Development allows any password and plain HTTP.
auth is any function that receives the Request and returns true to allow it, so you can check a session cookie from your existing login instead. Combine strategies with anyOf(...). If an identity-aware proxy such as Cloudflare Access already protects /prime, trustUpstream lets its visitors in, but only use it when nothing can reach the site except through that proxy. Security explains what that means on Cloudflare, and everything else prime checks.
Storage
On a server with a persistent disk, the default file-system storage works: saves are written atomically next to your code.
On serverless hosts there is no disk to keep. Use GitHub storage and let your existing CI rebuild:
import { githubStorage } from "@getprimecms/core";
export default defineConfig({
storage: githubStorage({
repo: "you/your-site",
branch: "main",
token: process.env.GITHUB_TOKEN!,
}),
});
The token needs Contents read and write on that repository. Every save is a commit, and proposals live in .prime/changesets in the same branch.
Uploaded images are committed to mediaDir like any other file. Your site serves them after its next build; until then the admin shows them through its own preview endpoint, so a fresh upload never appears broken while you write.
Cloudflare Workers
The admin runs on Workers with the Astro Cloudflare adapter and GitHub storage. Add the adapter, then read credentials from the environment in prime.config.ts:
// astro.config.mjs
import cloudflare from "@astrojs/cloudflare";
import prime from "@getprimecms/astro";
export default defineConfig({
adapter: cloudflare(),
integrations: [prime()],
});
// prime.config.ts
export default defineConfig({
auth: basicAuth({ username: process.env.PRIME_USER!, password: process.env.PRIME_PASSWORD! }),
storage: githubStorage({ repo: "you/your-site", token: process.env.GITHUB_TOKEN! }),
license: process.env.PRIME_LICENSE,
// ...
});
bunx wrangler secret put PRIME_PASSWORD # and PRIME_USER, GITHUB_TOKEN, PRIME_LICENSE
wrangler.jsonc needs "compatibility_flags": ["nodejs_compat"] and a compatibility date from 2025 or later, which is what makes secrets readable through process.env. Connect the repository to Workers Builds so each save prompts a rebuild. Pages render from what is in the repository at build time, so a save shows on the site once that build finishes. To use Cloudflare Access instead of a password, turn off the workers.dev address and preview URLs or protect them too, then use auth: trustUpstream; see Putting a proxy in front.
Validate in CI
bunx @getprimecms/cli check
check validates every entry against the schema and exits with an error if any entry is broken, so a hand edit with a bad date never reaches production.