Skip to content
BearMinion

← Blog

Let clients edit an Astro site without a terminal

Your client gets a web address, signs in with GitHub and edits the real page in the browser. Every save is a commit under their name, or a pull request you approve.

By default the BearMinion editor runs on your computer, while npm run dev runs. The online editor is the same editor at an address of its own, such as admin.example.com. Your client opens it, signs in with GitHub, edits and saves. The save is a commit, and your host publishes it like any other push.

Nobody clones anything, installs Node or opens a terminal. (Building sites for clients? Here's why freelancers hand over BearMinion sites.)

Who can edit

Access to the editor is access to the repository. There are no BearMinion accounts or passwords. Anyone who can push to the repo (owner, or a collaborator with Write or higher) can sign in and edit. Remove them from the repo and their saves stop working at once.

Set it up

You need the site on GitHub and a Vercel account. Vercel is the host the online editor is tested on.

1. Prepare the repository

Run:

npx bearminion@latest add hosted --install

Then commit and push. It adds the editor's settings (src/editor.ts), its own build (astro.editor.config.ts) and a build:editor script. Your astro.config.ts isn't touched, and the public site stays fully static.

2. Create a second Vercel project

Add another project from the same repository. The first one stays the public site.

  • Build Command: npm run build:editor
  • Deployment Protection: off for this project. The editor has its own sign-in.
  • Note its address. It must not be the public site's.

3. Create a GitHub App

On GitHub: Settings → Developer settings → GitHub Apps → New GitHub App. Use a GitHub App, not an OAuth App.

  • Callback URL: https://<the editor's address>/__bearminion/auth/callback
  • Expire user authorization tokens: on
  • Repository permissions: Contents and Pull requests, read and write. Metadata, read.
  • Webhook: off. Install it on this repository only.
  • If anyone but you will edit, make the App public. A private App only works for its owner.

Generate a client secret and keep it with the client ID.

4. Set four environment variables

In the editor's Vercel project, then redeploy:

  • BEARMINION_REPO: the repository as owner/name
  • GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET: from the App
  • SESSION_SECRET: 32 or more random characters, for example from openssl rand -base64 32

None of them goes in the repository or in the public site's project.

5. Sign in and invite

Open the editor's address, authorize the App once, change a heading and save. The commit carries your name.

To let your client in, add them to the repository as a collaborator with the Write role and send them the editor's address. If they don't have GitHub yet, send them Getting your client onto GitHub in 5 minutes.

The BearMinion editor around a page, with the page list on the left and the inspector on the right
What you and your client see after signing in: the real site, with the editor around it.

Review their edits first

By default each save is one commit on the main branch. For the first weeks, turn on pull request mode: add this to the createHostedEditor({ ... }) options in src/editor.ts:

store: { mode: 'pr' },

Each page then gets its own branch and pull request, and nothing goes live until you merge it on GitHub.

Worth knowing

  • Vercel is the tested host for the editor. The public site can live anywhere static.
  • Video uploads aren't available online yet. Link a video, or upload it locally.
  • History is the repository's commit history. There's no separate version list online.

Full details in Edit online.

Wake the minion.

One command to start the site. One more to hand it over.

  1. npm create bearminion@latest
  2. Created Crumb & Co. in crumb-co
  3. $npx bearminion add hosted
  4. Online editor ready
  5. →Next: invite your client on GitHub