Open In App

What are the steps to create first React Native App ?

Improve
Improve
Like Article
Like
Save
Share
Report

React Native is an open-source UI software framework created by Meta Platforms, Inc. It is used to develop applications for Android, Android TV, iOS, etc. We’re always looking for shorter development cycles, quicker time to deployment, and better app performance. And there are so many hybrid mobile frameworks such as NativeScript, React Native, Ionic, Xamarin, PhoneGap, etc.

React Native: It is a framework developed by Facebook for creating native-style apps for iOS & Android under one common language, JavaScript. Initially, Facebook only developed React Native to support iOS. However, with its recent support of the Android operating system, the library can now render mobile UIs for both platforms.

Building with React Native is extremely efficient and highly addictive but getting started can be a little tricky. React Native uses Node.js, a JavaScript runtime, to build your JavaScript code. If you don’t already have Node.js installed, it’s time to get it!

Installation: Here we will use the Expo CLI version which makes it much smoother to run your React Native applications. Follow the below steps one by one to set up your React native environment.

Expo: It is a framework and a platform for universal React applications. It is a set of tools and services built around React Native and native platforms that help you develop, build, deploy, and quickly iterate on iOS, Android, and web apps from the same JavaScript/TypeScript codebase.

Step 1: Open your terminal and run the below command.

npx create-expo-app project-name

Step 2: Now go into the created folder and start the server by using the following command.

cd "project-name"

Step 3: To start the react-native program, execute this command in the terminal of the project folder.

npx expo start

Then press ‘a’ or ‘i’ to open it in your android or ios emulator respectively.

Project Structure:

project structure

Example: In this example, we render a text and put some style on the text like text color.

App.js

Javascript




import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View } from 'react-native';
 
export default function App() {
    return (
        <View style={styles.container}>
            <Text style={styles.title}>
                Your react-native project has been created</Text>
            <Text style={styles.subtitle}>Welcome</Text>
            <StatusBar style="auto" />
        </View>
    );
}
 
const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: '#fff',
        alignItems: 'center',
        justifyContent: 'center',
    },
    title: {
        color: 'green',
        fontSize: 18,
    },
    subtitle: {
        color: 'red'
    }
});


Output:

App Preview



Last Updated : 17 Feb, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads