React Native is a popular JavaScript framework for building cross-platform mobile applications. It allows developers to write code once and deploy it on both iOS and Android platforms, reducing development time and effort. React Native is based on React, a JavaScript library for building user interfaces, and uses native components to render UI elements on mobile devices.
Before you start working with React Native, ensure you have Node.js and npm installed on your system. You can download the latest stable version from the official website: https://nodejs.org/
Open your terminal or command prompt and run the following command to install the React Native CLI globally:
npm install -g react-native-cli
For Android development:
For iOS development:
xcode-select --install
To create a new React Native project, open your terminal or command prompt and run the following command:
npx react-native init MyApp
Navigate to your React Native project directory and install the project dependencies using npm:
cd MyApp
npm install
React Native provides several built-in components for building the user interface of your app. Here are some commonly used components:
The View component is like a div in web development. It’s used to create containers for other components or elements.
import React from 'react';
import { View, StyleSheet } from 'react-native';
const App = () => {
return (
<View style={styles.container}>
{/* Your content here */}
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#f0f0f0',
},
});
export default App;
The Text component is used for displaying text in your app.
Styling in React Native is similar to CSS. You can use inline styles or the StyleSheet API to apply styles to your components. React Native uses flexbox for layout.
import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
const App = () => {
return (
<View style={styles.container}>
<Text style={styles.text}>Hello, React Native!</Text>
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#f0f0f0',
},
text: {
fontSize: 24,
fontWeight: 'bold',
color: 'blue',
},
});
export default App;
React Native provides various components to handle user input and events. For example, the TouchableOpacity component is used for touch events, similar to the onClick event in web development.

import React from 'react';
import { View, Text, TouchableOpacity, StyleSheet } from 'react-native';
const App = () => {
const handlePress = () => {
console.log('Button pressed!');
};
return (
<View style={styles.container}>
<TouchableOpacity onPress={handlePress}>
<Text style={styles.button}>Press Me</Text>
</TouchableOpacity>
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#f0f0f0',
},
button: {
paddingVertical: 10,
paddingHorizontal: 20,
backgroundColor: 'blue',
color: 'white',
borderRadius: 5,
},
});
export default App;
Navigation is essential for creating multi-screen apps. React Native provides various navigation libraries like React Navigation. Here’s an example of setting up basic navigation:
First, install the required libraries:
npm install @react-navigation/native @react-navigation/stack
Create a stack navigator:

import React from 'react';
import { View, Text, TouchableOpacity, StyleSheet } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
const HomeScreen = ({ navigation }) => {
return (
<View style={styles.container}>
<TouchableOpacity onPress={() => navigation.navigate('About')}>
<Text style={styles.button}>Go to About</Text>
</TouchableOpacity>
</View>
);
};
const AboutScreen = () => {
return (
<View style={styles.container}>
<Text>About Screen</Text>
</View>
);
};
const Stack = createStackNavigator();
const App = () => {
return (
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen name="Home" component={HomeScreen} />
<Stack.Screen name="About" component={AboutScreen} />
</Stack.Navigator>
</NavigationContainer>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#f0f0f0',
},
button: {
paddingVertical: 10,
paddingHorizontal: 20,
backgroundColor: 'blue',
color: 'white',
borderRadius: 5,
},
});
export default App;
To run your app on a physical device or emulator during development, use the following commands:
For Android:
npx react-native run-android
For iOS:
cd ios
pod install
cd ..
npx react-native run-ios
To conclude – if you are looking to build apps for android / ios without getting into complexity of learning 2 different programming languages i.e. JAVA or Kotlin for Android & Swift / Objective C for iOS, then React Native is the perfect alternative with least learning curve. Also it gives an easy entry for web developers into mobile development ecosystem who already have knowledge of Javascript / Typescript. Good luck with your mobile development journey !!
Hey, having any query? Our experts are just one click away to respond you.
Contact Us