Server functions

Deploy PocketBase hooks for server-side logic in your app.

Server functions are PocketBase hooks — JavaScript files that run on the backend when records change, on schedules, or via custom routes.

What hooks can do

  • Validate or transform data before save
  • Send emails or notifications
  • Call external APIs securely
  • Proxy V2 Cloud AI requests (recommended pattern)
  • Enforce business rules server-side

Creating hooks

Ask the AI in chat:

Or manage hooks in V2 Cloud → Server Functions:

  • List deployed hooks
  • Deploy new hook files
  • Delete outdated hooks

V2 Cloud AI via hooks

For production apps, call V2 Cloud AI from hooks instead of exposing keys in the client:

This keeps inference billing on your project owner's account while hiding implementation details.

Security

Hooks run with admin context on your PocketBase instance. Never hard-code secrets in hook source — use Secrets and inject at deploy time.