What this covers
A Pocketbase Backend service runs PocketBase and nothing else. Your application code runs as a separate App Hosting service and reaches the backend over its address. The backend keeps its data in pb_data/, outside each release, so deploys and rollbacks never touch it. The practices below come from the problems customers run into most often.
Before you start
Have your Pocketbase Backend service running and your superuser created at https://your-backend/_/. If you haven't set one up yet, start with Deploy a PocketBase backend.
How to do it
- Keep two services: PocketBase for data, sign-in and files, and your app on its own runtime. Give the app the backend's address as POCKETBASE_URL. An app deployed on the pocketbase runtime is not run.
- Define collections in code. Commit pb_migrations/ at the root of a repository and deploy it, so every schema change is reviewed and repeatable. Name migration files with a current timestamp: a file with an older timestamp is skipped without an error.
- Set API rules on every collection. A new collection is superuser-only, so your app gets 403 until you add a rule. Make each rule as narrow as the feature needs, for example @request.auth.id = user for records a user owns. A rule left empty and unlocked in the dashboard lets anyone in, including visitors who are not signed in.
- Use the superuser account only from server-side code, never from a browser. Keep its email and password in your app's environment variables, sign in with POST /api/collections/_superusers/auth-with-password, and give your end users their own accounts in the users collection.
- Keep secrets in your app, not in PocketBase. A backend service has no Environment Variables section. If a hook needs a setting, store it in a superuser-only collection such as config, and treat a missing value as 'feature off'.
- Turn on PocketBase's own scheduled backups under Settings → Backups and send them to an S3-compatible bucket. We copy pb_data/ every night as a safety net, which support restores for you; your own backup is the one you can restore yourself. Check that the first one arrives in the bucket.
- Keep large files in S3. Uploaded files live on the server's disk unless you turn on S3 storage in the dashboard's settings.
- Write cron jobs to check the current state. A run that falls in the few seconds of a restart or redeploy is skipped, not run late.
- Watch memory. PocketBase Starter is slowed down from about 680 MB and restarted past 1 GB. Paginate large list queries rather than loading whole collections.
- Log with $app.logger() in hooks for anything you will need later. console.log output only appears in the last 80 lines of the Runtime logs panel.
What our team checks
Support can check that your backend is running, that a deploy loaded your pb_migrations/ and pb_hooks/, and restore a nightly copy for a date you name. Support does not design your collections or API rules.
Next step
Open /_/ on your backend, review the API rules on every collection, then turn on scheduled backups.