Articles in this section

PocketBase WebHooks

Published:

Setting Up PocketBase Hooks on STACKS
PocketBase supports custom JavaScript hooks that let you add webhooks, custom API routes, and event triggers to your backend.
Steps:

Open your PocketBase container in the STACKS dashboard
Go to the File Manager
Create a new directory called pb_hooks inside /persist
Add your hook files to the pb_hooks directory (files must end in .pb.js)
Restart your container from the dashboard

Your hooks will be active after the restart.
Example webhook file (/persist/pb_hooks/notify.pb.js):
javascriptonRecordAfterCreateSuccess((e) => {
$http.send({
url: “https://your-app.com/webhook”,
method: “POST”,
headers: { “Content-Type”: “application/json” },
body: JSON.stringify({
event: “record.create”,
collection: e.record.collection().name,
record: e.record.publicExport()
})
})
e.next()
})
For more details, visit the official PocketBase hooks documentation: https://pocketbase.io/docs/js-overview/

Access denied
Access denied