Getting Started with React Native

Roshan Patil
Technology Hits
Published in
2 min readFeb 28, 2024
Image from flickr

React Native is a powerful framework for building mobile applications using JavaScript and React. With React Native, you can write code once and deploy it across multiple platforms, including iOS and Android, saving time and effort in the development process.

Installation

To get started with React Native, you’ll need to have Node.js installed on your machine. You can then use npm or yarn to install the React Native CLI globally:

npm install -g react-native-cli
# or
yarn global add react-native-cli

Once the CLI is installed, you can create a new React Native project by running:

react-native init MyProject

This will create a new directory called MyProject with all the necessary files and dependencies to start building your app.

Hello World

Let’s create a simple “Hello World” app to get a feel for how React Native works. Navigate into your project directory and open the App.js file in your text editor. Replace the contents of App.js with the following code:

import React from 'react';
import { Text, View } from 'react-native';

const App = () => {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>Hello, React Native!</Text>
</View>
);
};

export default App;

Save the file, then run your app using the following command:

npx react-native run-android
# or
npx react-native run-ios

This will start the React Native packager and launch your app on the specified platform.

Conclusion

That’s it! You’ve just created and run your first React Native app. This is just the tip of the iceberg, though. React Native offers a wide range of components and APIs for building robust mobile applications. Stay tuned for more tutorials on how to leverage the full power of React Native in your projects.

Happy coding!

--

--

Roshan Patil
Technology Hits

A React Native front-end enthusiast and dedicated development engineer, eager to expand knowledge on development techniques and collaborate with others