Skip to main content
The $app variable is the global PocketBase application instance available in all JavaScript hooks. It provides access to the database, settings, mailer, and more.

Global access

The $app variable is automatically available in all .pb.js and .pb.ts files:

Database queries

Find records

Query builder

For more complex queries, use the query builder:

Database transactions

Collections

Find collections

Create collections

Update collections

Authentication

Find auth records

Check permissions

Settings

Read settings

Update settings

File storage

Logging

Utilities

Data directory

Refresh token

Subscriptions

Examples

Custom email validation

Usage analytics

Custom admin command