Hook Examples
Ready-to-use cloud function recipes for the most common hook patterns.Auth Hooks
Invite-Only Registration
Only users with a valid invite code in their signup data can register. Hook:pre_register
Block Disposable Emails
Reject signups from known throwaway email services. Hook:pre_register
Onboarding: Create Default Records on Signup
Create a profile, default settings, and a welcome notification when a user registers. Hook:post_register
Suspend / Ban System
Block login for users flagged as banned, with a reason shown to the user. Hook:pre_login
Track Login Activity
Record every login with timestamp and increment a counter. Hook:post_login
Notify Team on New Signup (Slack)
Post a Slack message whenever a new user registers. Hook:post_register
SLACK_WEBHOOK_URL in your project’s environment config (Dashboard → Settings → Environment).
Collection Hooks
Auto-Timestamp Every Document
Addupdated_at to every document automatically on save.
Hook: pre_save
Note: Hooks cannot modify the document being saved. To set timestamps automatically, use cloud functions as your write endpoint instead, or handle it on the client side.
Sync to a Search Index
After a document is saved, push it to an external search service (e.g. Algolia, Meilisearch, Typesense). Hook:post_save
Remove from Search Index on Delete
Hook:post_delete
Archive Deleted Documents
Save a copy before deletion so data is never permanently lost. Hook:pre_delete
Notify on Document Change (Email)
Send an email when an order document’s status changes. Hook:post_save
Tips
Access Project Config in Hooks
Store API keys and secrets in your project’s environment config (Dashboard → Settings → Environment), then read them withconfig.get():
Don’t Block on External Calls
Forpre_login and pre_register hooks, always wrap external HTTP calls in try/except so a slow or failing external service doesn’t block your users:
One Function, Multiple Events
You can attach the same cloud function to multiple hook events and branch onreq.payload.get("event"):
