This is a monorepo built for React Native with support for mobile, macOS, Windows, and web using TypeScript. The monorepo structure enables shared code, improved build performance, and consistent development practices.
The project structure of the monorepo is as follows:
├── apps
│ ├── macos
│ ├── mobile
│ ├── web
│ └── windows
├── packages
│ ├── lib
│ └── shared
├── tsconfig.base.json
├── .eslintrc
└── package.json
apps
: Contains the native code for each specific platform:macos
,mobile
,web
, andwindows
.packages
: Contains thelib
andshared
subfolders.lib
: Used for a library or scoped code for reuse in other projects.shared
: Contains code to be shared among all platforms.
tsconfig.base.json
: Contains the base configuration for TypeScript that all packages extend..eslintrc
: Contains linting rules for the monorepo.package.json
: Contains the dependencies and scripts for the monorepo.
TypeScript is enabled in all packages, with project references used to improve build times. Types are shared between packages using the types
property in the package.json
file.
The monorepo includes linting and formatting tools to ensure consistency across the codebase. For TypeScript, ESLint, TSLint, and Prettier are used.
To get started with the monorepo, follow these steps:
- Clone the repo:
git clone git@github.com:psalishol/react-native-monorepo.git
- Install dependencies:
cd react-native-monorepo && yarn
To start the macOS Metro server, run:
yarn macos:start
To build the macOS app, run:
yarn macos
To start the Metro server for mobile, run:
yarn mobile:start
To build the app for Android, run:
yarn run android
To build the app for iOS, run:
yarn ios
To start the Next.js server for web, run:
yarn next:start
To start the Metro server for Windows, run:
yarn windows:start
To build the app for Windows, run:
yarn windows
Contributions to the monorepo are welcome! To contribute, fork the repo and create a new branch for your changes. Once you're done, create a pull request for review.
For more information on how to build a monorepo for React Native, please refer to the following resources: