# Password protection

Password-protect your site so only people with the password can open it. Visitors see a branded login page (not a browser popup) before they reach your app.

The gate covers your app's own address only. A PocketBase host (`pb-<app>.percher.run`) stays public; see [PocketBase](https://percher.app/docs/pocketbase#public-host).

**Every app is public by default** — its URL is openly reachable. Protection is opt-in and takes two steps that work together, then applies on your next deploy:

```sh
# 1. Turn on the gate — add this to your [web] block in percher.toml
[web]
password = true

# 2. Set the actual password (stored encrypted; never put it in percher.toml)
bunx percher env set SITE_PASSWORD=your-secret-here

# 3. Deploy — protection is applied during the deploy
bunx percher publish
```

Both pieces are required: `password = true` is the switch, `SITE_PASSWORD` is the secret. Setting one without the other does not protect the site.

- Verify: open your app's URL — you should see the login page before the app.
- Turn it off: set `password = false` (or remove the line) and deploy again.
- Rotate: change `SITE_PASSWORD` (`bunx percher env set SITE_PASSWORD=...`) — it takes effect without a redeploy, and existing login cookies stop working within about 30 seconds.

Available on all plans at no extra cost. A correct password sets a 7-day cookie, so visitors aren't asked again until it expires.

**Explicit form — `[web] visibility`.** `password = true` is the legacy alias for `visibility = "password"`; you can write either. The full field is:

```toml
[web]
visibility = "public" | "password" | "private"
```

`"public"` is the default (open to anyone). `"password"` is the SITE_PASSWORD gate above. `"private"` — a Percher-login gate where only the owner and the people you invite can open the app, each signed in with their own Percher account (no shared secret). Don't combine `visibility = "public"` with `password = true` — that's a contradiction and is rejected.

With `visibility = "password"`, set `SITE_PASSWORD` before you deploy. Only `password = true` blocks the deploy when the secret is missing; the explicit form does not, and the app then shows a login page nobody can pass.

Full guide: https://percher.app/docs/password-protection
