Supercharge Your Monorepo: Using Nx to Share React and React Native Code
2j2e
8 views
41 slides
Oct 28, 2025
Slide 1 of 41
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
About This Presentation
Discover how Nx, a powerful open-source build system, can streamline your development process by enabling seamless integration of React and React Native within the same monorepo. Learn how to maximize code sharing, enhance developer productivity, optimize CI performance, and maintain high code quali...
Discover how Nx, a powerful open-source build system, can streamline your development process by enabling seamless integration of React and React Native within the same monorepo. Learn how to maximize code sharing, enhance developer productivity, optimize CI performance, and maintain high code quality. This talk will cover practical techniques, tools, and best practices to make your cross-platform development workflow efficient and effective.
Size: 3.23 MB
Language: en
Added: Oct 28, 2025
Slides: 41 pages
Slide Content
Eugene Zharkov
Supercharge Your Monorepo
Using Nx to Share React and React Native Code
Package-Based Repo
Key Points
•Old school. Lerna-Like approach
•Independent Packages. Each app or library is treated as an independent package
with its own package.json.
•Decentralized dependency management. Dependencies are defined and installed
per project/library.
•Nx augmentation. Nx provides tooling for better build optimization and dependency
tracking, but the structure is more akin to traditional Lerna-style monorepos.
•Publishable libraries. Libraries are often standalone and can be versioned/published
independently to registries like npm.
Package-Based Repo
Usage
•Suitable for teams where apps or libraries need to be independent or
published to npm.
•Works for legacy setups migrating from Lerna or similar tools.
•Ideal when different teams work on distinct packages with minimal
dependencies between them.
Integrated Repo
Key Points
•Centralized structure. All applications and libraries are treated as part of a cohesive
system with a shared build system and tooling.
•Centralized dependency management. Nx manages dependencies for all projects
under a single root package.json.
•Nx-specific configuration. The entire repository is optimized using Nx’s build system
(e.g., caching, dependency graphs, affected commands).
•Scaffolded projects. Applications and libraries are generated and managed by Nx,
using its conventions and tools.
•Lightweight libraries. Libraries are not treated as standalone packages but as
reusable pieces of the monorepo.
Integrated Repo
Usage
•Best for tight integration between apps and libraries (e.g., shared
components, utilities).
•Suitable for teams focusing on developer productivity and build optimization.
•Great for repos where projects heavily depend on each other.
Integrated Repo
Usage
apps/
mobile-app/
src/
web-app/
src/
libs/
shared-components/
src/
custom-crypto-lib/
src/
package.json (centralized for the entire repo)
nx.json
workspace.json (or project.json files per app/library)
Initialize workspace
> yarn create nx-workspace
Workspace configuration
< a lot of configuration
< 6 minutes
metro.config
Extra configuration
const customConfig = {
cacheVersion: 'rider',
transformer: {
babelTransformerPath: require.resolve( 'react-native-svg-transformer'),
},
resolver: {
assetExts: assetExts.filter((ext) => ext !== 'svg'),
sourceExts: [...sourceExts, 'cjs', 'mjs', 'svg'],
},
};
module.exports = withNxMetro(mergeConfig(defaultConfig, customConfig), {
Change this to true to see debugging info.
Useful if you have issues resolving modules
debug: false,
all the file extensions used for imports other than 'ts', 'tsx', 'js', 'jsx', 'json'
extensions: [],
Specify folders to watch, in addition to Nx defaults (workspace libraries and node_modules)
watchFolders: [],
});
Pros
•Dependency Graph. Visualizes project dependencies, helping teams understand relationships between
apps and libraries.
•Smart Caching. Nx caches build outputs, tests, and linting results, reducing redundant work and speeding
up pipelines.
•Incremental Builds. Only affected parts of the project are rebuilt or retested based on changes, which is
ideal for CI/CD pipelines.
•Distributed Task Execution. Tasks can run in parallel across multiple machines for faster builds.
•Compatible with popular frameworks like React, Angular, Node.js, NestJS, React Native, Expo, and more.
•Custom Plugins. Developers can create custom plugins to extend functionality or integrate third-party
tools.
•Nx integrates seamlessly with CI tools like GitHub Actions, GitLab CI/CD, and Jenkins.
Cons
•Learning Curve. For teams unfamiliar with monorepos or advanced build systems, Nx can
feel complex initially.
•Understanding Nx-specific concepts like affected, dependency graphs, or caching requires
time.
•Extremely large monorepos (e.g., with thousands of projects) might require additional
configuration or infrastructure for optimal performance.
•Nx enforces specific tooling and workspace structure. Migrating away from Nx to a
different monorepo tool may be challenging.
•Migration to the new version is still a job.
•Stability is still an issue.