pocketbase-hooks

Solid

Server-side JavaScript hooks for PocketBase (pb_hooks). Use when writing custom routes, event hooks, cron jobs, sending emails, making HTTP requests, querying the database, or extending PocketBase with server-side logic. Covers the goja ES5 runtime, routing, middleware, all event hooks, DB queries, record operations, and global APIs.

API & Backend 27,984 stars 2901 forks Updated today MIT

Install

View on GitHub

Quality Score: 93/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# PocketBase Server-Side JavaScript (pb_hooks) ## Runtime Basics - Files go in `pb_hooks/*.pb.js` (must end with `.pb.js`) - Engine: **goja** — ES5.1 + some ES6. **No ES6 modules** (`import`/`export`), **no async/await**, **no arrow functions in older versions**. Use `function(){}` and CommonJS `require()`. - Each file is loaded on app start and on hot-reload - `__hooks` — absolute path to the pb_hooks directory - TypeScript declarations: `pb_data/types.d.ts` (auto-generated, useful for IDE support) - `--hooksPool=25` flag controls concurrent JS goroutines (default: 25) - Each handler runs in an isolated context — no shared mutable state between requests ## Routing ### Adding routes ```js routerAdd("GET", "/api/hello/{name}", function(e) { var name = e.request.pathValue("name") return e.json(200, { "message": "Hello " + name }) }, /* optional middleware */) ``` ### Path patterns - `{name}` — named path parameter - `{path...}` — wildcard (matches rest of path) - `{$}` — exact match (no trailing slash) ### Response methods | Method | Usage | |--------|-------| | `e.json(status, data)` | JSON response | | `e.string(status, text)` | Plain text | | `e.html(status, html)` | HTML response | | `e.redirect(status, url)` | Redirect (301/302) | | `e.blob(status, contentType, bytes)` | Binary data | | `e.stream(status, contentType, reader)` | Streaming response | | `e.noContent(status)` | No body (204) | ### Reading request data ```js // Body (JSON) var body = new Dynam...

Details

Author
davila7
Repository
davila7/claude-code-templates
Created
11 months ago
Last Updated
today
Language
Python
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category