The Building of React-native-web-start

Exploring the Development of a Cross-Platform Tool

React-native-web-start is designed to streamline web and mobile app development using React Native. This article explores its creation, challenges, and benefits.

React-native-web-start

Production-ready cross-platform starter template with Vite, TypeScript, and automated deployment.

Introduction: The Vision Behind React-native-web-start

As a Solutions Architect with years of experience building enterprise web applications like WebSpark, TeachSpark, ArtSpark, and PromptSpark, I've witnessed the evolution of cross-platform development firsthand.

The challenge has always been clear: how do you build modern, performant applications that work seamlessly across web, iOS, and Android without compromising developer experience or code quality?

React Native Web promised to solve this puzzle, so I thought I would take a shot at creating a starter template for my future projects. I wanted to have proper TypeScript integration, modern build tools, comprehensive documentation, and production-ready deployment pipelines.

Project Goals
  • Enterprise-grade foundation - Complete TypeScript integration with strict standards
  • Modern build tools - Vite for superior performance over Webpack
  • Comprehensive documentation - In-depth guides and troubleshooting resources
  • Production-ready CI/CD - Automated deployment with GitHub Actions

This article chronicles the entire journey from conception to production deployment, sharing every technical decision, challenge overcome, and lesson learned along the way.

The Genesis: Creating the GitHub Repository

Initial Repository Setup

The journey began with a simple git init command, but the planning that preceded it was extensive. After analyzing dozens of existing React Native Web projects, I identified key gaps that needed addressing:

Problems Identified
  • Outdated tooling (Webpack instead of Vite)
  • Incomplete TypeScript support
  • Poor documentation quality
  • No CI/CD pipeline
  • Missing production features
Solutions Implemented
  • Modern Vite build system
  • Strict TypeScript configuration
  • Comprehensive documentation
  • Automated GitHub Actions
  • Version tracking & SEO
Initial Repository Creation
# Initial repository creation
mkdir react-native-web-start
cd react-native-web-start
git init
git remote add origin https://github.com/markhazleton/react-native-web-start.git

Repository Structure Philosophy

I designed the repository structure with maintainability and scalability in mind, following enterprise patterns successfully implemented in WebSpark and other production applications:

react-native-web-start/
├── documentation/          # Comprehensive project documentation
├── src/                   # Application source code
│   ├── components/        # Reusable UI components
│   ├── screens/          # Screen-level components
│   ├── services/         # API and utility services
│   ├── types/            # TypeScript type definitions
│   └── utils/            # Helper functions
├── scripts/              # Build and utility scripts
├── .github/workflows/    # GitHub Actions CI/CD
├── public/               # Static assets for web
└── build-info/           # Generated build metadata

Foundation Architecture: Choosing the Right Stack

Technology Stack Analysis

Selecting the right technology stack was crucial for long-term success. After extensive research and testing, I chose:

Core Framework
  • React Native 0.74.0
    Latest stable version with improved performance
  • React Native Web 0.19.12
    Mature web compilation layer
  • TypeScript 5.2.2
    Strict type safety with latest features
Build System
  • Vite 7.0.6
    Lightning-fast development server
  • ESBuild
    Ultra-fast TypeScript compilation
  • Modern Defaults
    ES modules, tree-shaking, optimal chunking
Development Tools
  • ESLint & Prettier
    Code quality and formatting
  • Husky
    Git hooks for pre-commit validation
  • Jest
    Testing framework
Why Vite Over Webpack?

This decision deserves special attention as it significantly impacts developer experience:

Vite Advantages
  • Cold start performance: 10x faster than Webpack
  • Hot Module Replacement: Sub-second updates
  • Modern defaults: ES modules, tree-shaking
  • Rich plugin ecosystem with React Native Web support
Implementation Challenges
  • Configuring Vite for React Native Web
  • Alias resolution for cross-platform imports
  • Global variable definitions
  • Dependency optimization
Vite Configuration Implementation
vite.config.ts - Key Configuration
export default defineConfig({
  plugins: [react()],
  resolve: {
    alias: {
      'react-native': 'react-native-web',
      'react-native-vector-icons': '@expo/vector-icons',
    },
    extensions: ['.web.js', '.web.ts', '.web.tsx', '.js', '.ts', '.tsx'],
  },
  define: {
    global: 'globalThis',
    __DEV__: process.env.NODE_ENV === 'development',
  },
  optimizeDeps: {
    include: ['react-native-web'],
  },
});
Found this helpful?
Share it with your LinkedIn network

Setting Up the Development Environment

Package.json Configuration

The package.json file serves as the project's command center. I designed it with clear scripts for different development phases:

Key Package.json Scripts
"scripts": {
  "dev": "vite",
  "web": "vite",
  "generate-build-info": "node scripts/generate-build-info.js",
  "prebuild": "node scripts/generate-build-info.js && npm run copy-docs",
  "build": "vite build",
  "preview": "vite preview",
  "android": "react-native run-android",
  "ios": "react-native run-ios",
  "start": "react-native start"
}

TypeScript Configuration

Type safety is non-negotiable in enterprise applications. The tsconfig.json enforces strict standards while maintaining compatibility with modern JavaScript features.

tsconfig.json - Strict Configuration
{
  "compilerOptions": {
    "target": "ES2020",
    "useDefineForClassFields": true,
    "lib": ["ES2020", "DOM", "DOM.Iterable"],
    "module": "ESNext",
    "skipLibCheck": true,
    "moduleResolution": "bundler",
    "allowImportingTsExtensions": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx",
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noFallthroughCasesInSwitch": true
  }
}

GitHub Actions: Automating Deployment

The Evolution of CI/CD Pipeline

The GitHub Actions workflow went through several iterations before reaching production quality. Here's the final, battle-tested version:

Production-Ready Deployment Workflow
name: Deploy to GitHub Pages

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]
  workflow_dispatch:

permissions:
  contents: read
  pages: write
  id-token: write

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout repository
      uses: actions/checkout@v4
      with:
        fetch-depth: 0  # Fetch full history for git info

    - name: Setup Node.js 20
      uses: actions/setup-node@v4
      with:
        node-version: '20'
        cache: 'npm'

    - name: Install dependencies
      run: npm install --legacy-peer-deps

    - name: Generate build information
      run: node scripts/generate-build-info.js
      env:
        NODE_ENV: production
        GITHUB_RUN_NUMBER: ${{ github.run_number }}

    - name: Build application
      run: npm run build
      env:
        NODE_ENV: production
Key Deployment Challenges Solved
Challenges Encountered
  • Node.js Version Compatibility
    Initially used Node.js 18, but Vite 7.0.6 required Node.js 20
  • Dependency Resolution
    React Native Web's peer dependencies conflicted with React 18
  • Build Information in CI/CD
    Ensuring git information was available during build
  • Static Asset Handling
    Documentation files weren't being served properly
Solutions Implemented
  • Upgraded to Node.js 20
    For optimal Vite performance and crypto module support
  • --legacy-peer-deps Flag
    Used in both development and CI/CD for compatibility
  • fetch-depth: 0
    In checkout action for complete git history
  • Cross-Platform Scripts
    Node.js scripts instead of shell commands

SEO Optimization and Performance

Search Engine Optimization Strategy

As someone who builds web applications professionally, SEO was a critical consideration. The HTML meta tags were carefully crafted for maximum search visibility:

SEO Meta Tags Implementation
<!-- SEO Meta Tags -->
<title>React Native Web Vite Starter - Cross-Platform Development Template</title>
<meta name="description" content="Production-ready React Native Web starter template with Vite, TypeScript, and automated deployment." />
<meta name="keywords" content="react native web, vite, typescript, cross-platform" />

<!-- Open Graph Tags -->
<meta property="og:title" content="React Native Web Vite Starter" />
<meta property="og:description" content="Production-ready starter template for cross-platform applications" />
<meta property="og:type" content="website" />

Performance Optimization Strategies

Code Optimization
  • Code Splitting
    Lazy loading for better performance
  • Bundle Analysis
    Vite's built-in analyzer for optimization
  • Tree Shaking
    Automatic dead code elimination
Asset Optimization
  • SVG Icons
    Vector graphics instead of raster images
  • Font Loading
    Optimized web font delivery
  • Intelligent Caching
    Documentation service caching strategy

Lessons Learned and Best Practices

Technical Insights

Key Insights

Modern JavaScript ecosystems are complex. Using --legacy-peer-deps isn't ideal, but sometimes necessary for compatibility. Always document these decisions.

While "write once, run everywhere" is the goal, each platform has unique requirements. Build abstractions that handle these differences gracefully.

What works locally doesn't always work in CI/CD. Test your deployment pipeline thoroughly across different environments.

Architecture Patterns That Worked
  • Service Layer Pattern
    Abstracting API calls and platform-specific logic into services made the codebase maintainable
  • Configuration-Driven Development
    Using configuration objects instead of hardcoded values made the application adaptable
  • Progressive Enhancement
    Building core functionality first, then adding platform-specific enhancements
Mistakes to Avoid
Premature Optimization

Don't optimize for performance before establishing functionality. Get it working, then make it fast.

Ignoring Platform Differences

Platform differences aren't just UI concerns. Navigation, file system access, and networking all vary.

Insufficient Error Handling

Production applications need robust error handling, especially for network requests.

The Future: What's Next

Planned Enhancements

Mobile & Testing
  • Mobile Platform Integration
    Full iOS and Android builds with native features
  • Automated Testing Suite
    Jest, Playwright for comprehensive testing
  • Performance Monitoring
    Real-time application performance tracking
Architecture & APIs
  • State Management
    Redux Toolkit or Zustand for complex scenarios
  • API Integration Examples
    Comprehensive API integration patterns
  • Community Contributions
    Enhanced documentation and contribution guidelines

Enterprise Adoption

Based on patterns successful in WebSpark and other production applications, the project incorporates scalable architecture patterns, security best practices, performance optimization techniques, and comprehensive monitoring and logging.

Conclusion

Building react-native-web-start was more than creating another starter template – it was about establishing enterprise-grade patterns for cross-platform development.

The journey from initial git commit to production deployment revealed the complexities of modern web development: dependency management challenges, CI/CD pipeline intricacies, cross-platform compatibility issues, and the critical importance of comprehensive documentation.

Key Achievements
  • Enterprise-grade cross-platform foundation
  • Production-ready CI/CD pipeline
  • Comprehensive documentation system
  • Modern tooling with Vite and TypeScript
Knowledge Shared
  • Complete development journey documentation
  • Troubleshooting guides for common issues
  • Best practices for cross-platform development
  • Real-world production experience insights

The project demonstrates that with careful planning, proper tooling, and attention to detail, it's possible to create applications that truly work across all platforms without compromising code quality or developer experience.

Every challenge overcome – from React dependency conflicts to GitHub Pages deployment issues – was documented not just for troubleshooting, but as knowledge for the broader development community. This transparency and attention to detail transforms a simple starter template into a valuable resource for developers worldwide.

Get Started with React-native-web-start

Ready to build your own cross-platform application? Clone the repository and start developing today!