You can extend the default PocketBase behavior with custom server-side code using the exposed JavaScript app event hooks.

Throwing an error or not calling e.next() inside a handler function stops the hook execution chain.

All hook handler functions share the same function(e){} signature and expect the user to call e.next() if they want to proceed with the execution chain.

    These are lower level Record model hooks and could be triggered from anywhere (custom console command, scheduled cron job, when calling e.save(record), etc.) and therefore they have no access to the request context!

    If you want to intercept the builtin Web APIs and to access their request body, query parameters, headers or the request auth state, then please use the designated Record *Request hooks .

    These are lower level Collection model hooks and could be triggered from anywhere (custom console command, scheduled cron job, when calling e.save(collection), etc.) and therefore they have no access to the request context!

    If you want to intercept the builtin Web APIs and to access their request body, query parameters, headers or the request auth state, then please use the designated Collection *Request hooks .

    The request hooks are triggered only when the corresponding API request endpoint is accessed.

    The Model hooks are fired for all PocketBase structs that implements the Model DB interface - Record, Collection, Log, etc.

    For convenience, if you want to listen to only the Record or Collection DB model events without doing manual type assertion, you can use the onRecord* and onCollection* proxy hooks above.