This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
Build lifecycle hooks
Edit page
Learn how to use the Expo Build lifecycle hooks with npm to customize your build process.
Expo Build lifecycle npm hooks allows you to customize your build process by running scripts before or after the build process.
For better understanding, see the Android build process and the iOS build process.
The lifecycle hooks are not executed by the build process in custom builds. They need to be manually extracted and called by the build steps during the process.
Expo Build lifecycle hooks
There are six Expo Build lifecycle npm hooks available. To use, them, you can set them in your package.json.
An example of how a package.json can look when using one or more lifecycle hooks:
Platform-specific hook behavior
To run a script (or some part of a script) only for Android or iOS builds, you can fork the behavior depending on the platform within the script. See the following common examples to do this through a shell script or a Node script.
Examples
package.json and shell script
Because the hook calls ./pre-install directly, the pre-install file needs execute permission. Set the permission and commit the change, so that Git records it with the file:
Without execute permission, the hook fails with a Permission denied error. Another option is to call the script with bash, as in "eas-build-pre-install": "bash ./pre-install". Then the file does not need execute permission.
Example: Pre-install script that installs git-lfs on macOS workers
The following script installs git-lfs if it is not yet installed. This is useful in some cases where git-lfs is required to install certain CocoaPods.