Re.Pack adds minimal support for Expo managed projects. Since Re.Pack replaces Metro, some Expo features may not work as expected. Please refer to the limitations section for more details.
Expo is a popular framework for building React Native applications. Re.Pack provides a plugin to integrate with Expo managed projects, allowing you to leverage Re.Pack's bundling capabilities while still using Expo's features.
Using Expo with Re.Pack requires some setup - this guide will show you how to get started with Expo in your project.
Install the Expo package in your project:
First, install the official Re.Pack Expo plugin:
Then, add the plugin to your configuration file:
This step is crucial as it ensures that React Native CLI will be used when building for production instead of Expo CLI, which is not compatible with Re.Pack.
Modify your app.json
or app.config.js
to include the following configuration:
After completing the setup, you can start using Re.Pack in your Expo application.
To generate a development build of your Expo application, run the following command:
After running this command, you can develop using the default Re.Pack workflow.
@callstack/repack-plugin-expo
has built-in support for Expo Router.
If you haven't already, install the Expo Router and its dependencies:
Add expo-router
to the plugins array in your app.json
or app.config.js
along with the Re.Pack plugin:
Modify the plugin configuration in your rspack.config.cjs
to enable the router support:
You can also customize the base URL and root directory for the router:
Do not use expo-router/entry
as your entry point when using Re.Pack. This entry point is designed to work with Metro bundler and may not function correctly with Re.Pack.
Change your application entry point to use the router's ExpoRoot
component. Update your App.js
as follows:
When using Re.Pack with Expo managed projects, there are some limitations to be aware of:
expo start
, expo run android
and expo run ios
) will not work as expected. Use React Native CLI commands instead (e.g., npx react-native start
, npx react-native run-android
, npx react-native run-ios
)..d.ts
files for Expo Router.