react-cross-platform-cli
This project servers as a simple command line interface. One can use it to generate a boilerplate project for a cross platform react application.
Included platforms
The following platforms are supported in the boilerplate application:
Installation
Install the CLI globally on your machine using npm
:
npm install -g react-cross-platform-cli
The recommended package manager is yarn
. If you don't have it installed, you can let the CLI do it for you. If you don't want to use yarn, the CLI will go on using npm
as package manager.
The CLI uses react-native-cli
to initialize the application. You can either install react-native-cli
manually or let the CLI do this for you.
Usage
To run the CLI simply type
react-cross-platform-cli init
The CLI will ask you for a project name and the platforms you want to use. (Android and iOS are always default, Web and Desktop are optinal.)
The CLI then creates a new folder in your working directory with the boilerplate application.
After that you have multiple options for running your application from the command line, each depending on the device:
npm run andoid
: Runs the application on a virtual Android device. For setup instructions look here.npm run ios
: Runs the application on a virtual iPhone. For setup instructions look here.npm run web
: Runs webpack-dev-server
on port 3000
. You can look at your application via http://localhost:3000.
You have also extended options here, look them up here.npm run desktop
: Runs the application in a new window on your desktop.
The single source of truth for all devices is the App-Component located in app.js
. Simply use this as your main component and import all custom components there, then you never should have to actually touch any of the platform-specific files.
Credits