WHAT YOU'LL LEARN
  • 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
anchor

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
anchor

Each project application — Core, Api, and Admin — exposes the same set of hook extensions:

ExtensionWhen it runs
Infra.[ProjectApplication].BeforeBuildBefore the application code is compiled
Infra.[ProjectApplication].AfterBuildAfter the application code is compiled
Infra.[ProjectApplication].BeforeDeployBefore compiled code and infrastructure are deployed
Infra.[ProjectApplication].AfterDeployAfter compiled code and infrastructure are deployed
Infra.[ProjectApplication].BeforeWatchBefore 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
anchor

Register API hooks in webiny.config.tsx:

webiny.config.tsx

Each hook file exports a default implementation using the DI pattern:

extensions/hooks/api/BeforeBuild.ts
extensions/hooks/api/AfterDeploy.ts

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).