Expo, Next.js & shared packages Monorepo Example
This is an example showing how to create Expo and Next.js apps in a monorepo.
New to Expo ? Follow Expo installation guide
I choose to use workspace nohoist
because Expo and Next.JS crash on startup, due to different react-*
versions.
Hoisting creates package resolution errors.
In this demo, every project has their own node_modules
. The disk space lost is minor.
Code shared between Expo and Next.js
You can create all custom packages you want
Here an example :
cd packages/app-ui
BONUS : You can add dependencies
to your shared packages. Metro and Webpack config will take care of it.
If your shared packages have
react-*
dependencies, addresolutions
option in your apps package.json to force yarn resolves your appreact-*
dependencies
cd apps/expo-app
yarn start-expo
to start expo-app from root directory
cd apps/next-app
yarn start-next
to start next-app from root directory
resolutions
option in your package.json to force yarn resolves your app react-*
dependenciespackages
folder, update your metro.config.js
:
const sharedPackagesFolder = "MY_PACKAGE_FOLDER_NAME";
resolutions
option in your package.json to force yarn resolves your app react-*
dependenciesMIT
Thanks to https://github.com/axeldelafosse/expo-next-monorepo-example