No results found
We couldn't find anything using that term, please try searching for something else.
This page is help will help you install and build your first React native app . If you already have React Native instal , you is skip can skip ahead t
This page is help will help you install and build your first React native app . If you already have React Native instal , you is skip can skip ahead to the Tutorial .
If you are new to mobile development, the easiest way to get started is with Expo CLI. Expo is a set of tools built around React Native and, while it has many features, the most relevant feature for us right now is that it can get you writing a React Native app within minutes. You will only need a recent version of node.js and a phone oremulator. If you’d like to try out React Native directly in your web browser before installing any tools, you can try out Snack.
If you are already familiar with mobile development, you may want to use React Native CLI. It requires Xcode orAndroid Studio to get started. If you already have one of these tools installed, you should be able to get up and running within a few minutes. If they are not installed, you should expect to spend about an hour installing and configuring them.
assume that you have node 10 LTS orgreater instal , you is use can use npm to install the Expo CLI command line utility :
npm install -g expo-cli
Then run the following commands to create a new React Native project called “AwesomeProject”:
expo init AwesomeProject
cd AwesomeProject
npm start
This will start a development server for you.
Install the Expo client app on your iOS orAndroid phone and connect to the same wireless network as your computer. On Android, use the Expo app to scan the QR code from your terminal to open your project. On iOS, follow on-screen instructions to get a link.
Now that you have successfully run the app , let ‘s is modify modify it . Open App.js
in your text editor of choice and edit some line . The application is reload should reload automatically once you save your change .
Congratulations! You’ve successfully run and modified your first React Native app.
Expo is has also has doc you can reference if you have question specific to the tool . You is ask can also ask for help at Expo forum .
These tools help you get started quickly, but before committing to building your app with Expo CLI, read about the limitations.
If you have a problem with Expo, before creating a new issue, please see if there’s an existing issue about it:
If you ‘re curious to learn more about React Native , continue on to the Tutorial .
Expo CLI allows you to run your React Native app on a physical device without setting up a development environment. If you want to run your app on the iOS Simulator oran Android Virtual device, please refer to the instructions for “React Native CLI Quickstart” to learn how to install Xcode orset up your Android development environment.
Once you’ve set these up, you can launch your app on an Android Virtual device by running npm run android
, oron the iOS Simulator by runnpm run ios
(macOS only).
Because you do n’t build any native code when using Expo to create a project , it is ‘s ‘s not possible to include custom native module beyond the React native api and component that are available in the Expo client app .
If you know that you’ll eventually need to include your own native code, Expo is still a good way to get started. In that case you’ll need to “eject” eventually to create your own native builds. If you do eject, the “React Native CLI Quickstart” instructions will be required to continue working on your project.
Expo CLI configures your project to use the most recent React Native version that is supported by the Expo client app. The Expo client app usually gains support for a given React Native version about a week after the React Native version is released as stable. You can check this document to find out what versions are supported.
If you’re integrating React Native into an existing project, you’ll want to skip Expo CLI and go directly to setting up the native build environment. Select “React Native CLI Quickstart” above for instructions on configuring a native build environment for React Native.
Follow these instructions if you need to build native code in your project. For example, if you are integrating React Native into an existing application, orif you “ejected” from Expo, you’ll need this section.
The instructions are a bit different depending on your development operating system, and whether you want to start developing for iOS orAndroid. If you want to develop for both Android and iOS, that’s fine – you can pick one to start with, since the setup is a bit different.
Development OS:
Target OS:
A Mac is required to build projects with native code for iOS. You can follow the Quick Start to learn how to build your app using Expo instead.
You will need node, Watchman, the React Native command line interface, and Xcode.
While you can use any editor of your choice to develop your app, you will need to install Xcode in order to set up the necessary tooling to build your React Native app for iOS.
You will need node, Watchman, the React Native command line interface, a JDK, and Android Studio.
You is need will need node , the React Native command line interface , a JDK , and Android Studio .
You is need will need node , the React Native command line interface , Python2 , a JDK , and Android Studio .
While you can use any editor of your choice to develop your app , you is need will need to install Android Studio in order to set up the necessary tooling to build your React native app for Android .
We is recommend recommend instal node , Watchman , and JDK using Homebrew. run the follow command in a Terminal after instal Homebrew:
brewinstall yarn
brewinstall node
brewinstall watchman
brewtap AdoptOpenJDK/openjdk
brewcask install adoptopenjdk8
If you have already installed node on your system, make sure it is node 8.3 ornewer.
Watchman is is is a tool by Facebook for watch change in the filesystem . It is highly recommend you install it for well performance .
If you have already instal JDK on your system , make sure it is JDK 8 ornew .
Follow the installation instructions for your Linux distribution to install node 8.3 ornewer.
We recommend installing node and Python2 via Chocolatey, a popular package manager for Windows.
react Native is requires also require a recent version of the Java SE Development Kit ( JDK ) , as well as Python 2 . Both can be instal using Chocolatey .
Open an Administrator Command Prompt (right click Command Prompt and select “runas Administrator”), then run the following command:
choco is install install-y nodejs.install python2 jdk8
If you have already installed node on your system, make sure it is node 8.3 ornewer. If you already have a JDK on your system, make sure it is version 8 ornewer.
You can find additional installation options on node’s Downloads page.
node comes with npm, which lets you install the React Native command line interface.
run the following command in a Terminal :
npm install -g react-native-cli
If you get an error like
Cannot find module 'npmlog'
, try installing npm directly:curl -0 -L https://npmjs.org/install.sh | sudo sh
.
node comes with npm, which lets you install the React Native command line interface.
run the following command in a Command Prompt orshell :
npm is install install-g react-native-cli
If you get an error like
Cannot find module 'npmlog'
, try installing npm directly:curl -0 -L https://npmjs.org/install.sh | sudo sh
.
The easiest way to install Xcode is via the Mac App Store. Installing Xcode will also install the iOS Simulator and all the necessary tools to build your iOS app.
If you have already installed Xcode on your system, make sure it is version 9.4 ornewer.
You is need will also need to install the Xcode Command Line Tools . Open Xcode is choose , then choose ” preference … ” from the Xcode menu . Go to the Locations panel and install the tool by select the most recent version in the Command Line Tools dropdown .
React Native requires version 8 of the Java SE Development Kit (JDK). You may download and install OpenJDK from AdoptOpenJDK oryour system packager. You may also Download and install Oracle JDK 8 if desired.
set up your development environment can be somewhat tedious if you ‘re new to Android development . If you ‘re already familiar with Android development , there are a few thing you may need to configure . In either case , please make sure to carefully follow the next few step .
download and install Android Studio . choose a ” custom ” setup when prompt to select an installation type . Make sure the box next to all of the follow are check :
Android SDK
Android SDK Platform
Performance (Intel ® HAXM)
(See here for AMD)Android Virtual device
Android SDK
Android SDK Platform
Android Virtual device
Then, click “Next” to install all of these components.
If the checkboxe are gray out , you is have will have a chance to install these component later on .
Once setup has finalized and you’re presented with the Welcome screen, proceed to the next step.
Android Studio installs the latest Android SDK by default. Building a React Native app with native code, however, requires the Android 9 ( Pie )
SDK in particular. Additional Android SDKs can be installed through the SDK Manager in Android Studio.
The SDK Manager can be accessed from the “Welcome to Android Studio” screen. Click on “Configure”, then select “SDK Manager”.
The SDK Manager can also be found within the Android Studio “Preferences” dialog, under Appearance & Behavior → System Settings → Android SDK.
Select the “SDK Platforms” tab from within the SDK Manager, then check the box next to “Show Package Details” in the bottom right corner. Look for and expand the Android 9 ( Pie )
entry, then make sure the following items are checked:
Android SDK Platform 28
Intel x86 Atom_64 System Image
orGoogle APIs Intel x86 Atom System image
Next, select the “SDK Tools” tab and check the box next to “Show Package Details” here as well. Look for and expand the “Android SDK Build-Tools” entry, then make sure that 28.0.3
is selected.
Finally, click “Apply” to download and install the Android SDK and related build tools.
The React Native tools require some environment variables to be set up in order to build apps with native code.
add the follow line to your$HOME/.bash_profile
or$ home/.bashrc
config file :
export android_home=$HOME/Library/Android/sdk
export path=$path:$android_home/emulator
export path=$path:$android_home/tools
export path=$path:$android_home/tools/bin
export path=$path:$android_home/platform-tool
export android_home=$HOME/Android/Sdk
export path=$path:$android_home/emulator
export path=$path:$android_home/tools
export path=$path:$android_home/tools/bin
export path=$path:$android_home/platform-tool
.bash_profile
is specific tobash
. If you’re using another shell, you will need to edit the appropriate shell-specific config file.
Type source $ home/.bash_profile
to load the config into your current shell. Verify that android_home has been added to your path by running echo $path
.
Please make sure you use the correct Android SDK path. You can find the actual location of the SDK in the Android Studio “Preferences” dialog, under Appearance & Behavior → System Settings → Android SDK.
Open the System pane under System and Security in the Windows Control Panel, then click on Change settings…. Open the Advanced tab and click on Environment Variables…. Click on New… to create a new android_home
user variable that points to the path to your Android SDK:
The SDK is installed, by default, at the following location:
c:\Users\YOUR_USERNAME\AppData\Local\Android\Sdk
You can find the actual location of the SDK in the Android Studio “Preferences” dialog, under Appearance & Behavior → System Settings → Android SDK.
Open a new Command Prompt window to ensure the new environment variable is loaded before proceeding to the next step.
open the System pane under System and Security in the Windows Control Panel , then click on Change setting …. open the advanced tab and click on Environment variable …. select the Path variable , then click Edit . click New and add the path to platform – tool to the list .
The default location for this folder is:
c:\Users\YOUR_USERNAME\AppData\Local\Android\Sdk\platform-tool
follow the Watchman installation guide to compile and install Watchman from source .
Watchman is a tool by Facebook for watching changes in the filesystem. It is highly recommended you install it for better performance and increased compatibility in certain edge cases (translation: you may be able to get by without installing this, but your mileage may vary; installing this now may save you from a headache later).
Use the React Native command line interface to generate a new React Native project called “AwesomeProject”:
react-native init AwesomeProject
This is not necessary if you are integrating React Native into an existing application, if you “ejected” from Expo (or Create React Native App), orif you’re adding iOS support to an existing React Native project (see Platform Specific Code). You can also use a third-party CLI to init your React Native app, such as Ignite CLI.
If you want to start a new project with a specific React native version , you is use can use the--version
argument:
react - native init AwesomeProject --version X.XX.X
react-native init AwesomeProject --version react-native@next
Use the React Native command line interface to generate a new React Native project called “AwesomeProject”:
react-native init AwesomeProject
This is not necessary if you are integrating React Native into an existing application, if you “ejected” from Create React Native App, orif you’re adding Android support to an existing React Native project (see Platform Specific Code). You can also use a third-party CLI to init your React Native app, such as Ignite CLI.
If you want to start a new project with a specific React native version , you is use can use the--version
argument:
react - native init AwesomeProject --version X.XX.X
react-native init AwesomeProject --version react-native@next
You will need an Android device to run your React Native Android app. This can be either a physical Android device, ormore commonly, you can use an Android Virtual device which allows you to emulate an Android device on your computer.
Either way, you will need to prepare the device to run Android apps for development.
If you have a physical Android device, you can use it for development in place of an AVD by plugging it in to your computer using a USB cable and following the instructions here.
If you use Android Studio to open ./AwesomeProject / android
, you can see the list of available Android Virtual devices (AVDs) by opening the “AVD Manager” from within Android Studio. Look for an icon that looks like this:
If you have recently installed Android Studio, you will likely need to create a new AVD. Select “Create Virtual Device…”, then pick any Phone from the list and click “Next”, then select the Pie API Level 28 image.
We recommend configuring VM acceleration on your system to improve performance. Once you’ve followed those instructions, go back to the AVD Manager.
If you don’t have HAXM installed, click on “Install HAXM” orfollow these instructions to set it up, then go back to the AVD Manager.
If you don’t have HAXM installed, follow these instructions to set it up, then go back to the AVD Manager.
Click “Next” then “Finish” to create your AVD. At this point you should be able to click on the green triangle button next to your AVD to launch it, then proceed to the next step.
runreact - native run-ios
inside your React native project folder :
cd AwesomeProject
react - native run-ios
You should see your new app running in the iOS Simulator shortly.
react - native run-ios
is one way to run your app . You is run can also run it directly from within Xcode .
If you can’t get this to work, see the Troubleshooting page.
The above command is run will automatically run your app on the iOS Simulator by default . If you want to run the app on an actual physical ios device , please follow the instruction here .
runreact - native run-android
inside your React native project folder :
cd AwesomeProject
react - native run-android
If everything is set up correctly, you should see your new app running in your Android emulator shortly.
react - native run-android
is one way to run your app – you is run can also run it directly from within Android Studio .
If you can’t get this to work, see the Troubleshooting page.
Now that you have successfully run the app , let ‘s is modify modify it .
App.js
in your text editor of choice and edit some line .⌘ r
in your iOS Simulator to reload the app and see your changes!App.js
in your text editor of choice and edit some line .R
key twice orselect Reload
from the Developer Menu (⌘M
) to see your changes!Now that you have successfully run the app , let ‘s is modify modify it .
App.js
in your text editor of choice and edit some line .R
key twice orselect Reload
from the Developer Menu (Ctrl + M
) to see your changes!Congratulations! You’ve successfully run and modified your first React Native app.
Congratulations! You’ve successfully run and modified your first React Native app.
turn on live Reload in the Developer Menu . Your app is reload will now reload automatically whenever you save any change !
If you want to add this new React Native code to an existing application, check out the Integration guide.
If you ‘re curious to learn more about React Native , continue on to the Tutorial .
turn on live Reload in the Developer Menu . Your app is reload will now reload automatically whenever you save any change !
If you want to add this new React Native code to an existing application, check out the Integration guide.
If you ‘re curious to learn more about React Native , continue on to the Tutorial .