React native projects creating goes with the help of command line interface (react-native-cli package). react-native-desktop adds a modification to that package to support desktop platform.
If all the projects you develop need desktop support, you can install modified command line interface globally by following these steps
After that you create a new project:
react-native init DesktopSampleApp
cd DesktopSampleAppAlternative and more flexible way is to install original react-native-cli:
npm install -g react-native-cli # Or use YarnAnd create project that uses a react-native-desktop repo:
react-native init DesktopSampleApp --version status-im/react-native-desktopSince we used original react-native-cli, desktop-related files aren't in project yet. So we should initialize them:
cd DesktopSampleApp
react-native desktopIf you're using macOS, run these commands in 2 different shells (from DesktopSampleApp dir):
npm start #starts bundlernode node_modules/react-native/ubuntu-server.js #starts js serverAfterwards, in a 3rd shell execute:
react-native run-desktopCompilation of desktop project will start. When it finished and app run you can see following:
Note: On non-macOS systems, npm start and node ubuntu-server.js will be executed automatically by the above command
If you want to know why you had to start bundler and js server - check the doc on how react-native-desktop works internally
