How to Install React Native on Windows

Β·

3 min read

You have heard about the wonders of React Native and how it can help you ship native code for both Android and IOS using the same codebase. And that's why you're here today - to learn how to get started.

Luckily, not long ago I was just like you, so I decided to document my experience in order to help you.

Prerequisites

You need to have Node, JDK, and Android Studio installed. Follow me as I show you how to install them.

Installing Node

Please visit the official website to download and install Node version 14 or newer. The current LTS version as of the time of writing this article is Node 18.

Installing JDK

JDK is short for Java Development Kit, and it offers a collection of tools and libraries necessary for developing Java applications.

I recommend using Chocolatey - a very popular package manager for Windows - to install the JDK. Please see this very simple and straightforward installation guide to have it installed on your Windows machine.

After successfully installing Chocolatey, please run the command below to install the JDK11. We are using JDK11 because we are likely to encounter issues with newer versions.

choco install -y microsoft-openjdk11

Now let's make sure that we have successfully installed the JDK by running the command below. Please note that you may need to restart the command prompt and "Run as administrator".

If you encounter a problem where the command is not working, please go to your environment variables and edit the System Variables which can be found in the steps below ☟

  1. Open the Windows Control Panel.

  2. Click on User Accounts

  3. Click User Accounts again

  4. Click on Change my environment variables

Add the JAVA_HOME variable with the value set to the path for the Java executable. Java is typically installed (on Windows) as C:\Program Files\Java\jdk<version>.

Now restart the command prompt and run the java --version command again.

Installing Android Studio

We will not be making use of Android studio for development, however, we need to install it as an easy way to set up the necessary tooling to build our React Native app for Android.

Head over to the Android Studio website to download and install the latest version 😎. The installation is actually very straightforward.

During the installation of Android Studio, confirm that the boxes next to each of the following items are checked:

  • Android SDK
  • Android SDK Platform

  • Android Virtual Device

Add ANDROID_HOME to Environment Variables

Next, run the adb --version command to ensure that everything is fine ☟

If you have gotten to this point, it means that everything is fine. Yaay πŸ‘

Now we can run the command below to create a new project

npx react-native init projectName

That would be all for today. If you found this article helpful please share itπŸ™πŸ».

Β