Skip to content
Back to skills

Pocketbase

ASecurity

Build backends with PocketBase collections, auth, and realtime.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 11, 2026
developmentjavascriptgojavasqlapibackend

Works with

  • api

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned November 11, 2026

npx -y skills add johnalbertini14-glitch/openclaw-skills --skill pocketbase --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Pocketbase?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Pocketbase
[![Security: A β€” Skills Directory](https://www.skillsdirectory.com/api/skills/johnalbertini14-glitch-pocketbase/badge)](https://www.skillsdirectory.com/skills/johnalbertini14-glitch-pocketbase)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: PocketBase
description: Build backends with PocketBase collections, auth, and realtime.
metadata: {"clawdbot":{"emoji":"πŸ“¦","requires":{"bins":["pocketbase"]},"os":["linux","darwin","win32"]}}
---

## SDK Basics
- Import from `pocketbase` not `pocketbase/dist` β€” the dist path is internal and breaks on updates
- Always check `pb.authStore.isValid` before using `pb.authStore.model` β€” expired tokens return stale data without error
- After login, token is auto-attached to requests β€” no need to manually set Authorization headers

## Fetching Records
- Use `expand` parameter to load relations: `pb.collection('posts').getList(1, 20, { expand: 'author,comments' })`
- Expanded records appear in `record.expand.fieldName` β€” not directly on the record object
- Filter syntax is SQL-like but uses single quotes: `filter: "status = 'active' && created >= '2024-01-01'"`
- Combine conditions with `&&` and `||`, not `AND`/`OR` β€” SQL keywords don't work

## Authentication
- Users collection is `users` (lowercase) β€” `_users` or `Users` returns empty results
- `authWithPassword(email, password)` returns the full user record plus token
- OAuth flow: `authWithOAuth2({ provider: 'google' })` opens popup automatically in browser
- Logout requires both `pb.authStore.clear()` and invalidating server-side if using tokens elsewhere

## Realtime
- Subscribe with `pb.collection('posts').subscribe('*', callback)` β€” the `'*'` means all record changes
- Callback receives `{ action: 'create'|'update'|'delete', record }` β€” check action before processing
- Always unsubscribe on cleanup: `pb.collection('posts').unsubscribe()` β€” orphan subscriptions leak memory

## File Uploads
- Files require FormData, not JSON: `formData.append('document', file)` then pass to `create()`
- Get file URL with `pb.files.getURL(record, record.filename)` β€” don't construct URLs manually
- Multiple files to same field: append with same key multiple times

## Collection Rules
- Empty rule = blocked for everyone, `""` (empty string) rule = open to everyone β€” counterintuitive
- Use `@request.auth.id` to reference logged-in user, `@request.data` for submitted data
- Example restrict to owner: `@request.auth.id = user.id` in View/Update/Delete rules

## Hooks (pb_hooks/)
- JavaScript hooks go in `pb_hooks/*.pb.js` β€” the `.pb.js` extension is required
- Hooks run synchronously and block the request β€” keep them fast or use routines
- Access app with `$app`, event data with `e` β€” common: `e.record`, `e.httpContext`

## Admin API
- Admin endpoints need superuser auth, not regular user tokens
- Create admin token: `pb.admins.authWithPassword(email, password)`
- Admin operations use `pb.admins` or `pb.collections`, not `pb.collection()`

Files in this skill

  • SKILL.md2.7 KB
  • _meta.json277 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development β†’

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.