Deployments and Infrastructure > Extensions > Build and Deploy Hooks
Build and Deploy Hooks
Run custom logic before or after build, deploy, and watch steps for each project application.
- What lifecycle hooks are available for the Core, API, and Admin project applications
- How to run custom logic before or after build, deploy, and watch steps
- How to register hooks in
webiny.config.tsx
Overview
When you run webiny deploy or webiny watch, Webiny executes a build step followed by a deploy step for each project application (Core, API, Admin). You can hook into any of these steps using Infra.* lifecycle extensions registered in webiny.config.tsx.
Available Hooks
Each project application — Core, Api, and Admin — exposes the same set of hook extensions:
| Extension | When it runs |
|---|---|
Infra.[ProjectApplication].BeforeBuild | Before the application code is compiled |
Infra.[ProjectApplication].AfterBuild | After the application code is compiled |
Infra.[ProjectApplication].BeforeDeploy | Before compiled code and infrastructure are deployed |
Infra.[ProjectApplication].AfterDeploy | After compiled code and infrastructure are deployed |
Infra.[ProjectApplication].BeforeWatch | Before the watch process starts |
Where [ProjectApplication] is one of Core, Api, or Admin.
All hooks can be used multiple times — if you register multiple hooks for the same lifecycle event, they are executed in order.
Example: API Application
Register API hooks in webiny.config.tsx:
Each hook file exports a default implementation using the DI pattern:
The same pattern applies to the Admin and Core project applications — replace Api with Admin or Core in both the Infra.* component names and the import paths (webiny/infra/admin, webiny/infra/core).