Edit Page
Hooks
What is a hook?
A hook is a Node module that adds functionality to the Sails core. The hook specification defines the requirements a module must meet for Sails to be able to import its code and make the new functionality available. Because they can be saved separately from the core, hooks allow Sails code to be shared between apps and developers without having to modify the framework.
Types of hooks
There are three types of hooks available in Sails:
- Core hooks are built in and provide many of the common features essential to a Sails app, such as request handling, blueprint route creation, and database integration via Waterline. Core hooks are bundled with the Sails core and are thus available to every app. You will rarely need to call core hook methods in your code.
- App-level hooks live in the
api/hooks/
folder of a Sails app. Project hooks let you take advantage of the features of the hook system for code that doesn’t need to be shared between apps.
- Installable hooks are plugins, installed into an app’s
node_modules
folder using npm install
. Installable hooks allow developers in the Sails community to create “plug-in”-like modules for use in Sails apps.
Read more
Is something missing?
If you notice something we've missed or could be improved on, please follow this link and submit a pull request to the sails repo. Once we merge it, the changes will be reflected on the website the next time it is deployed.
Check out the full Sailsconf 2024 playlist on Youtube
Documentation