DocsPermissions & hooks · FRL
On this page

Normalize records with hooks

Prepare incoming data and respond after a write.

FRL lets a theme shape data before it is saved, then run tidy follow-up work after a write is accepted. This is how a frontend-first theme gets clean slugs, trusted status fields, counters, audit records, notifications, and other production behavior without a custom server project.

Before Hooks

Use before when incoming post data needs to be cleaned or completed before schema validation and permission checks.

backend/index.frl
Rule input (JSON)

Use a complete version 2 rule file. Select a post with “postType” and “action”, or an “endpoint” by name. Saved data, jobs, payments and email need the local server. Dedupe replay protection also needs a site.

Check complete rules or run schemas, permissions, hooks and calculations against the input above. Add excerpts to a complete rule before running.

before only works for write actions: create, edit, delete, and write. write means create, edit, and delete together. Read actions such as get, list, and read do not have before hooks.

In before create and before edit, write to $post.pending.data. That is the data Frontbacked will validate and save. Use $post.current.data only when you need the previously saved value.

Ordering

When multiple before blocks match, Frontbacked runs them in the order they appear in the file.

backend/index.frl
Rule input (JSON)

Use a complete version 2 rule file. Select a post with “postType” and “action”, or an “endpoint” by name. Saved data, jobs, payments and email need the local server. Dedupe replay protection also needs a site.

Check complete rules or run schemas, permissions, hooks and calculations against the input above. Add excerpts to a complete rule before running.

For a create, the example runs before write, then before create, edit, then before create. The same $context moves through the whole rule run.

Action Metadata

Use $action when a shared block needs to know which operation is running.

frl

Rule excerpt: add this to a complete FRL rule before running it. Try a complete example →

For post and user rules, $action.isWrite is true for create, edit, and delete. $action.isRead is true for get and list.

After Hooks

Use after for follow-up work that should run only after validation and permissions pass.

backend/index.frl
Rule input (JSON)

Use a complete version 2 rule file. Select a post with “postType” and “action”, or an “endpoint” by name. Saved data, jobs, payments and email need the local server. Dedupe replay protection also needs a site.

Check complete rules or run schemas, permissions, hooks and calculations against the input above. Add excerpts to a complete rule before running.

after uses the same write-action list as before: after create, after edit, after delete, after write, or comma-separated groups such as after create, edit. It does not run for get, list, or read.

Continue with Update related records.