Mobile Micro Frontends with React Native Expo: WebView Architecture and Real-World Implementation
Deep dive into implementing micro frontend architecture in mobile apps using React Native Expo and WebViews. Real production experiences, performance data, and proven patterns. Includes Rspack, Re.Pack, and alternative bundler approaches.
Mobile teams increasingly face the challenge of integrating multiple web-based services from different teams, each with their own deployment cycles and tech stacks. Tight delivery timelines compound this complexity when web teams can't pause their development to assist with mobile integration.
Micro frontend architecture offers a solution for React Native apps using WebViews. This approach involves significant debugging, performance optimization, and creative problem-solving. Here's what works in practice.
Mobile Micro Frontend Series
This is Part 1 of a comprehensive 3-part series on mobile micro frontends:
- Part 1 (You are here): Architecture fundamentals and WebView integration patterns
- Part 2: WebView communication patterns and service integration
- Part 3: Multi-channel architecture and production optimization
New to mobile micro frontends? Start here to understand the architecture and implementation basics.
Ready to implement? Jump to Part 2 for communication patterns.
Running in production? Check Part 3 for optimization strategies.
Why Mobile Micro Frontends?
Traditional mobile app development has a fundamental problem: native code deployment is slow. App store reviews, user update adoption, and coordinating releases across multiple teams create bottlenecks that web developers solved years ago.
Common constraints in this scenario include:
- 5 different web teams with existing React/Vue/Angular applications
- Weekly web deployments vs monthly mobile releases
- A/B testing requirements that couldn't wait for app updates
- Compliance features that needed immediate deployment capability
The solution? Embed web-based micro frontends in our React Native app using WebViews.
Architecture Overview
Here's the high-level architecture we implemented:
The native app acts as a shell that:
- Handles authentication and session management
- Provides native functionality (camera, biometrics, etc.)
- Manages navigation between micro frontends
- Implements a communication bridge between WebViews and native code
Alternative Approaches: Beyond Traditional WebViews
Before diving into our WebView implementation, let me share the alternative approaches we evaluated and why we chose WebViews over them.
Option 1: Re.Pack with Module Federation
Re.Pack is Callstack's solution for bringing Module Federation to React Native. It's essentially webpack's Module Federation running in React Native.
What we tried:
Why we didn't choose it:
- Complexity: Required significant changes to our existing webpack configurations
- Team coordination: All teams needed to adopt Re.Pack simultaneously
- Debugging: Module Federation debugging in React Native was still immature
- Performance: Initial bundle size increased by 40% due to federation overhead
When to use Re.Pack:
- You're starting fresh with a new project
- All teams can coordinate on the same bundler
- You need true runtime module sharing
- You're building a "super app" with multiple independent teams
Option 2: Rspack with React Native
Rspack is a Rust-based bundler that's webpack-compatible but much faster. We experimented with using Rspack for our micro frontend builds.
What we tried:
Why we didn't choose it:
- React Native compatibility: Rspack doesn't have native React Native support yet
- Ecosystem maturity: Fewer plugins and loaders compared to webpack
- Team adoption: Would require retraining 5 teams on a new bundler
- Production stability: We couldn't risk our timeline on a newer tool
When to use Rspack:
- You're building web-only micro frontends
- Build performance is critical (Rspack is 10x faster than webpack)
- You can afford to be an early adopter
- Your teams are comfortable with Rust-based tooling
Option 3: Vite + React Native
We also evaluated using Vite for our micro frontend builds, leveraging its fast HMR and modern build system.
What we tried:
Why we didn't choose it:
- Module Federation: Vite's Module Federation support was still experimental
- Production builds: Our production builds were slower than webpack
- Plugin ecosystem: Fewer plugins for our specific needs
- Team familiarity: Teams were more comfortable with webpack
When to use Vite:
- You're building modern web applications
- Development speed is more important than production optimization
- You don't need complex Module Federation
- Your teams prefer modern tooling
Option 4: Hybrid Approach (What We Actually Did)
After evaluating all options, we chose a hybrid approach that gave us the best of all worlds:
Why this worked:
- Team autonomy: Each team could use their preferred bundler
- Gradual migration: Teams could migrate to better tools over time
- Risk mitigation: If one approach failed, others continued working
- Performance: Each team could optimize their own builds
Implementation: The Real Story
Setting Up the WebView Architecture
We started with Expo's WebView, but quickly ran into our first challenge. The initial implementation looked deceptively simple:
This worked for exactly 5 minutes in development before we hit our first production issue: the WebView would randomly show a white screen on Android devices with less than 4GB RAM.
The Memory Problem
Crash reporting often reveals WebViews consuming 150-200MB each. Multiple micro frontends can hit memory limits on lower-end devices. Here's a solution:
The Bundle Size Problem
Initial micro frontend bundles often reach 2-3MB each, causing slow loading times and poor user experience. Here's how to optimize:
Alternative: Rspack Configuration
For teams that wanted to try Rspack, here's the equivalent configuration:
Performance comparison:
- Webpack build time: 45 seconds
- Rspack build time: 8 seconds (82% faster)
- Bundle size: Similar (within 5%)
- Memory usage: Rspack uses 30% less memory during builds
The Navigation Problem
WebView navigation doesn't work like native navigation. Users expect the back button to work, but WebViews have their own history. Here's our solution:
Performance Results
These optimizations typically lead to significant improvements:
Loading Performance
- Initial load time reductions of 60-70%
- Bundle size reductions of 50-60%
- Memory usage reductions of 35-45% per WebView
User Experience
- Substantial crash rate reductions (90%+)
- White screen incident reductions (90%+)
- Improved user satisfaction scores
Build Performance
- Webpack build improvements of 20-25%
- Rspack builds typically 80%+ faster than webpack
- Development HMR improvements of 80%+
Key Takeaways
-
WebViews are viable but require optimization: They work well for micro frontends but need careful memory and performance management.
-
Hybrid approaches work best: Let teams use their preferred tools while maintaining a consistent interface.
-
Rspack shows promise: For new projects, consider Rspack for its speed and webpack compatibility.
-
Re.Pack is powerful but complex: Great for super apps but requires significant coordination.
-
Performance is critical: Users notice slow WebViews immediately. Optimize aggressively.
What's Next?
In Part 2, we'll dive into:
- Building a robust communication bridge between WebViews and native code
- Type-safe message passing
- Handling authentication and native features
- Debugging and monitoring strategies
The foundation is crucial. Get the architecture right, and everything else becomes manageable. Get it wrong, and you'll be fighting performance issues forever.
Next time, we'll look at how to make WebViews and native code talk to each other reliably, and the debugging nightmares we solved along the way.
Mobile Micro Frontends with React Native
A comprehensive 3-part series on building mobile micro frontends using React Native, Expo, and WebViews. Covers architecture, communication patterns, and production optimization.