Dynamic page hooks, also known as data binding router hooks, run custom code at specific points during the page routing and loading process. Unlike regular data hooks that run during data operations, dynamic page hooks let you intercept the routing process when a visitor requests a dynamic page. You can use these hooks to validate requests, modify data queries, or customize the page response.
Dynamic page hooks run in a specific sequence during the routing process. You can implement any or all of these hooks depending on your needs.
The hooks run in the following order:
If you also have regular data hooks defined, they run between customizeQuery and afterRouter in the sequence.
Dynamic page hooks follow specific naming and file conventions. Define hooks in the routers.js file in the site's backend folder and use the router prefix in their function names.
For detailed information about hook conventions, parameters, and implementation, see the Router hooks reference.