Hook Discovery Tool
Search and discover Drupal hooks available in core and popular contributed modules.
Drupal Hook System — How It Works
Drupal's hook system is the primary way modules intercept and extend core functionality without modifying core files. A hook is simply a function in your module following the naming convention MODULENAME_hookname(). When Drupal invokes a hook, it calls every implementation of that hook in every enabled module.
Hooks are defined in .module files or in dedicated service classes registered through the event system in Drupal 8+. Unlike WordPress hooks, Drupal hooks are discovered at bootstrap time and cached — there is no add_action() equivalent. If your module file defines the function, it will be called automatically.
Implementing a Hook
In your mymodule.module file:
/**
* Implements hook_node_presave().
*/
function mymodule_node_presave(\Drupal\node\NodeInterface $node) {
if ($node->bundle() === 'article') {
// Your logic here.
}
}
Hooks vs. Event Subscribers
Drupal 8+ introduced Symfony's event system as an alternative to hooks for many subsystems. Event subscribers offer better performance through dependency injection and can be unit tested more easily. However, many Drupal-specific operations (entity operations, form alters, theme preprocessing) still rely on hooks. Use hooks for Drupal-specific integrations and event subscribers for Symfony-level events.