November 15, 2018

1161 words 6 mins read

react-community/create-react-native-app

react-community/create-react-native-app

Create a React Native app on any OS with no build config.

repo name react-community/create-react-native-app
repo link https://github.com/react-community/create-react-native-app
homepage
language JavaScript
size (curr.) 651 kB
stars (curr.) 11778
created 2017-01-11
license BSD 3-Clause “New” or “Revised” License

Create React Native App

Note: This repository has been archived and the issue tracker for Create React Native App has moved to: https://github.com/expo/expo-cli/issues

Backers on Open Collective Sponsors on Open Collective npm version

Create React Native apps with no build configuration.

Once you’re up and running with Create React Native App, visit this tutorial for more information on building apps with React Native.

Note: Create React Native App has been merged with Expo CLI You can now use expo init to create your project. See Quick Start in the Expo documentation for instructions on getting started using Expo CLI.

The create-react-native-app command is provided for backwards compatibility.

If you created your app using create-react-native-app, it’s already compatible with Expo CLI. See upgrade instructions.

Quick Overview

Make sure you have Node v6 or later installed. No Xcode or Android Studio installation is required.

$ npm install -g expo-cli
$ expo init my-app
$ cd my-app/
$ npm start

The npm start command starts the Expo CLI server. You can now run the project on your phone by using the Expo app.

Android

  • Install the Expo app on your Android device.
  • Scan the QR code in your terminal from the Expo app to run the project on your phone.
  • Alternatively you can press ’s' in the terminal and sign in with an Expo account, and sign in with the same account in the Expo app: your projects will automatically appear in the “Projects” tab.

iOS

  • Install the Expo app on your iOS device.
  • Press ‘e’ in the terminal to send the app link to your email address or phone number. This link can be used to run your project from the Expo app.
  • Alternatively you can press ’s' in the terminal and sign in with an Expo account, and sign in with the same account in the Expo app: your projects will automatically appear in the “Projects” tab.

Expo CLI allows you to work with all of the Components and APIs in React Native, as well as the JavaScript APIs that the Expo app provides.

Sections

Getting Started

Installation

See Installation.

Creating an App

To create a new app, run:

expo init

This will create a directory called my-app inside the current working directory. Inside my-app, this will generate the initial project structure and install all of its dependencies.

If you’re familiar with React Native already, you won’t find any ios or android directories in this project, just JavaScript. Once this installation is done, there are some commands you can run in the project directory:

npm start

Runs your app in development mode with an interactive prompt. To run it without a prompt, use the --no-interactive flag.

Open it in the Expo app on your phone to view it. It will reload if you save edits to your files, and you will see build errors and logs in the terminal.

npm test

Runs the jest test runner on your tests.

npm run ios

Like npm start, but also attempts to open your app in the iOS Simulator if you’re on a Mac and have it installed.

npm run android

Like npm start, but also attempts to open your app on a connected Android device or emulator. Requires an installation of Android build tools (see React Native docs for detailed setup).

npm run eject

This will start the process of “ejecting” from Create React Native App’s build scripts. You’ll be asked a couple of questions about how you’d like to build your project.

Warning: Running eject is a permanent action. Please use a version control system, such as git, so you can revert back if necessary. An ejected app will require you to have an Xcode and/or Android Studio environment set up.

Philosophy

  • Minimal “Time to Hello World”: Create React Native App should reduce the setup time it takes to try building a mobile app to the absolute minimum, ideally on par with React web development (especially as seen with Create React App).
  • Develop on Your Device: It should be easy to develop on a physical device when you want to test how your app feels and responds to inputs.
  • One Build Tool: If you just want to get started with React Native, you shouldn’t need to install Xcode, Android Studio, NDKs, or mess with environment variables.
  • No Lock-In: You can always “eject” to your own build setup if you need to write custom native code or modify how your app is built.

Support and Contact

If you’re having issues with Create React Native App, please make sure:

  • The issue is not covered in the Expo Docs
  • There is not already an open issue for your particular problem

If you’ve checked the documentation and currently open issues, please either open a new GitHub issue or ask a question on Expo forums. Please do not DM or email project maintainers directly, as it’s very important that support takes place in public locations where others can benefit from the conversation.

FAQs

What API specification should I be looking at while developing?

Apps made with Create React Native App support everything in the Components and APIs sections of the React Native Documentation.

Apps made with Create React Native App also support most of the JavaScript-to-Native APIs provided by the Expo SDK, since they are loaded by the Expo app.

What are the limitations of Create React Native App?

The main limitation of a Create React Native App project is that it must be written in pure JavaScript and not have any dependencies which rely on custom native code (i.e. ones which require running react-native link to work). This allows the projects to load directly on a phone without native compilation, and also means that it’s not necessary to install or use Android Studio or Xcode.

What if I want to write custom native code for my app?

If you’re sure that you need custom native code, please read the ejecting guide.

How do I get my app into the Play Store/App Store?

If you need to build IPAs and APKs for publishing to the App Store and/or Play Store, you can either eject (see above guide) and build them yourself using Xcode and Android Studio, or you can use a service like Expo’s standalone app builds to publish your pure JS app.

Contributing

From version v2.0.1, Create React Native App has been merged with Expo CLI.

Please see Contributin to Expo CLI in the Expo CLI monorepo for instructions on contributing to Expo CLI.

Contributors

This project exists thanks to all the people who contribute. [Contribute].

Backers

Thank you to all our backers! 🙏 [Become a backer]

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

comments powered by Disqus