Standalone
A standalone site brings its own services. It’s more to set up than CaraCMS Cloud, and nothing depends on anyone else.
For now, caracms init and the config file spell this mode self-hosted, as the commands on this page show. npm create caracms already calls it Standalone.
npx caracms init --self-hosted --writeexport default defineSite({ services: 'self-hosted', // …});What you need
Service | What for | Needed |
|---|---|---|
A GitHub token or App | Saving drafts and publishing to the site’s repo | Always |
Redis | Drafts and sessions | Always |
An email account with Resend | Sign-in links and form emails | For email sign-in and forms |
A media bucket and imgproxy | Storing and resizing images | If the site has images |
A second bucket | Form submissions | If the site has forms |
A Mux account | Video clips | If the site has video |
The variables
These go on the site’s server. caracms init prints the same list.
Name | Needed | What it’s for |
|---|---|---|
GITHUB_REPO | Required | The site’s repository, as owner/name. |
CARACMS_GITHUB_TOKEN | Required, or the App | A fine-grained token on that one repo. |
GITHUB_APP_ID and GITHUB_APP_PRIVATE_KEY | Instead of the token | A GitHub App, for anyone running many sites. |
SITE_URL | Required | The site’s public address, https. The same value at build and at run time. |
REDIS_URL | Required | A redis:// or rediss:// address. |
CARACMS_SECRET | Required | Signs editors’ sessions. A long random string. |
CARACMS_CLIENT_IP_HEADER | Required off Railway, Fly and Render | Where the visitor’s IP comes from. See Where the server runs. |
CARACMS_ALLOW | For email sign-in | Who may sign in: addresses, or whole domains written as @example.com. |
RESEND_API_KEY and FORMS_FROM | For email sign-in and form emails | The Resend key, and the address emails come from. |
CARACMS_BACKUP_USER and CARACMS_BACKUP_PASSWORD | Optional | A backup sign-in for when email links can’t arrive. Both or neither. |
CARACMS_DEPLOY_HOOK_URL | Optional | Lets the editor’s Try again redeploy the site through the host’s deploy hook. |
Set email sign-in, the backup sign-in or both. With neither, nobody can sign in.
A site that uses images, video or forms needs these as well:
Feature | Variables |
|---|---|
Images | CARACMS_MEDIA_URL (imgproxy’s address), IMGPROXY_KEY, IMGPROXY_SALT, S3_BUCKET, S3_ENDPOINT, S3_REGION, S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY |
Video | MUX_TOKEN_ID, MUX_TOKEN_SECRET |
Form submissions | SUBMISSIONS_S3_BUCKET, SUBMISSIONS_S3_ACCESS_KEY_ID, SUBMISSIONS_S3_SECRET_ACCESS_KEY |
Spam checks on forms | TURNSTILE_SITE_KEY, TURNSTILE_SECRET_KEY |
A password on the whole site before launch | CARACMS_PRELAUNCH |
The image variables and TURNSTILE_SITE_KEY are read when the site is built too, so set them in both places.
When something required is missing or wrong, the public site still serves and /admin answers with a sentence saying what to fix.
GitHub: a token or an App
CaraCMS writes to the site’s repo with one of two credentials. Set one, not both.
A fine-grained token
On GitHub, go to Settings, Developer settings, Personal access tokens, Fine-grained tokens, and generate a new token.
Set the resource owner to whoever owns the site’s repo, and give it access to only that repo.
Give it Contents, read and write. Add Deployments, read, if your host writes GitHub Deployments: it lets the editor show a failed deploy.
Pick an expiry and set the token as CARACMS_GITHUB_TOKEN.
A classic token is refused, because it reaches every repo its owner can. The token is tied to a person and it expires; the editor warns 14 days before it does. Its rate limits are shared by every site on that person’s tokens, so past a handful of sites, use the App.
A GitHub App
An App has its own rate limit per site, signs every commit, and isn’t tied to a person. Use it when you run more than a handful of sites, or when the repo requires signed commits. Install it on the site’s repo only, with the same permissions as the token.
Two things to do in the repo
Protect the drafts branch from deletion. It holds every change saved since the last Publish, and to a branch tidy-up it looks like any stale branch. Add a branch ruleset that targets drafts and turns on Restrict deletions only. Leave Block force pushes off: Publish moves the branch with a forced update.
Roll the site back with a revert, never a force-push. A revert is a new commit on main, which the drafts take in like any push:
git revert <commit>git pushResetting main to an older commit and force-pushing leaves the rolled-back content waiting in the editor, and the next Publish puts it back.
Images
Originals go in an S3-compatible bucket. imgproxy reads from it and serves each size the site asks for, and CaraCMS signs every image address. To put local images into the bucket from the command line:
npx caracms media import photos/*.jpgllms.txt · llms-full.txt: this site for AI tools