A demonstration project showing how to share business logic between React (web) and React Native (mobile) applications. Interestingly, with precisely zero marketing effort in managed to get several thousands of app store downloads in a year or so.

Context

In 2017, the promise of “write once, run anywhere” with React Native was appealing, but the reality was more nuanced. This project explored what code could actually be shared between web and mobile React apps.

The Experiment

Podorozhnik (named after the Russian word for “plantain” / travel card) is a simple calculator app implemented twice:

  1. React (Web): Standard React application
  2. React Native (Mobile): Native mobile app

Both share the same business logic, while the UI components are platform-specific.

Findings

  • Business logic (calculations, state management) shares well
  • UI components need platform-specific implementations
  • The “learn once, write anywhere” philosophy is more accurate than “write once, run anywhere”
  • Shared code can live in a common module imported by both platforms

Git repo