App Builder Application Tooling Lifecycle Event Hooks
Hooks can be defined to run before, after, or in place of many app plug-in commands in the app.config.yaml or ext.config.yaml file of your app.
Command support
aio app run
supports:
Copied to your clipboardhooks:pre-app-run: echo pre-app-runpost-app-run: echo post-app-runpre-app-build: echo pre-app-buildpost-app-build: echo post-app-buildpre-app-deploy: echo pre-app-deploypost-app-deploy: echo post-app-deploybuild-actions: echo build-actionsdeploy-actions: echo deploy-actionsbuild-static: echo build-staticserve-static: echo serve-staticpre-app-undeploy: echo pre-app-undeploypost-app-undeploy: echo post-app-undeployundeploy-actions: echo undeploy-actionsundeploy-static: echo undeploy-static
aio app build
supports:
Copied to your clipboardhooks:pre-app-build: echo pre-app-buildpost-app-build: echo post-app-buildbuild-actions: echo build-actionsbuild-static: echo build-static
aio app deploy
supports:
Copied to your clipboardhooks:pre-app-build: echo pre-app-buildpost-app-build: echo post-app-buildpre-app-deploy: echo pre-app-deploypost-app-deploy: echo post-app-deploybuild-actions: echo build-actionsbuild-static: echo build-staticdeploy-actions: echo deploy-actionsdeploy-static: echo deploy-static
aio app undeploy
supports:
Copied to your clipboardhooks:pre-app-undeploy: echo pre-app-undeploypost-app-undeploy: echo post-app-undeployundeploy-actions: echo undeploy-actionsundeploy-static: echo undeploy-static
aio app test
supports:
Copied to your clipboardhooks:test: echo this is your custom test runner
aio app pack
supports:
Copied to your clipboardhooks:pre-pack: echo this is before packagingpost-pack: echo this is after packaging
Use cases
aio app run
hooks manage local development tooling not managed by flows included with App Builderaio app build
build-static and build-actions hooks:Build actions to include static files with action zipfiles, for example, templates in server-side rendering
Build web assets with different bundlers and configurations, for example webpack
aio app deploy
deploy-static and deploy-actions hooks support additional deployment steps, for example to deploy to multiple servers or locationsaio app undeploy
undeploy-static and undeploy-actions hooks support additional un-deployment steps, for example to undeploy from multiple servers or locationsaio app test
test hooks support custom test runners for apps and extensions
Using JavaScript files
You can specify a JavaScript file that contains your hook code. The file must export a function.
app.config.yaml
Copied to your clipboardhooks:post-app-deploy: ./hooks/post-app-deploy.js
./hooks/post-app-deploy.js
Copied to your clipboardmodule.exports = () => {console.log("Post app deploy hook")}
Legacy App with no extensions
Add a hooks
key in the app.config.yaml
file under the application
key in the root of your app. For example:
Copied to your clipboardapplication:hooks:pre-app-run: echo pre-app-run
If you add extensions to a standalone app using aio app add extension
, app.config.yaml
hooks will always run first, followed by extension hooks in each ext.config.yaml
file.
App with extensions
In the app extension folder, typically at src/EXTENSION_NAME
, find the ext.config.yaml
file and add a hooks
key. For example:
Copied to your clipboardhooks:pre-app-run: echo pre-app-run
App-Hooks flow
These diagrams show how custom hooks are run, built, deployed, and undeployed within applications by commands:
Next steps
Return to Architecture Overview.
Return to Guides Index.