
During my job, my senior staff approached me and said: "We have this React web project, but we also need it as a mobile application." At first, I was a bit unsure how to approach it efficiently. So I decided to research ways to create native applications from a single codebase. 📱💻
Normally, writing separate code for Web, Android, and iOS can take a lot of time and effort. Today, I discovered a fantastic platform called Capacitor. Using Capacitor, you can take your React code and build it for Android, iOS, and Web — all from a single codebase. 🚀
Capacitor is a modern cross-platform framework created by the team behind Ionic. It allows web developers to use **one codebase** to deploy applications on multiple platforms. Essentially, your React app runs inside a native container, giving you access to native device APIs while still writing in React.
Capacitor is ideal in many scenarios:
Here’s a step-by-step guide to get your React app running as a native mobile application:
npm install @capacitor/core @capacitor/cli
npx cap init
npm run build
npm install @capacitor/android npx cap add android npm run build npx cap copy npx cap open android
✅ Note: npx cap copy copies your React build files into android/app/src/main/assets/public/
npx cap sync
✅ This will copy your new web assets and also update native dependencies if plugins or configurations change.
Before adding iOS platform, make sure you have the following:
sudo gem install cocoapodsxcode-select --installxcode-select -p xcodebuild -version
npx cap add ios npm run build npx cap copy ios npx cap open ios
✅ Now you can run your app on a simulator or a real iOS device.
Capacitor is a game-changer for developers who know React and want to create native apps efficiently. It saves time, simplifies deployment, and allows you to use a single codebase for multiple platforms. If your clients ever ask for both web and mobile versions, Capacitor is the perfect solution. ✨


