How to Scaffold a New React Native Project

Table of Contents
Big thanks to our contributors those make our blogs possible.

Our growing community of contributors bring their unique insights from around the world to power our blog. 

Introduction

Getting started with mobile development can feel like navigating a maze: dozens of tools, configurations, and platform quirks stand between you and your first “Hello, world!” app. React Native bridges that gap by letting you use JavaScript and React to build truly native Android and iOS apps from a single codebase. In this guide, you’ll learn how to scaffold a brand-new React Native project from scratch—step by step, with clear code examples, best practices, and expert tips. Whether you’re a web developer dipping your toes into mobile or a seasoned engineer evaluating React Native for your next big app, this post will equip you to go from zero to running on device in under 15 minutes.

Understanding React Native and Why It Matters

React Native is Facebook’s open-source framework that compiles JavaScript and React components into native UI elements. Instead of WebViews, your app uses true mobile widgets—buttons, lists, text inputs—under the hood.

  • Cross-platform efficiency: One codebase for iOS and Android.
  • Live Reload & Fast Refresh: Instant updates in the simulator as you code.
  • Strong ecosystem: Thousands of community packages for navigation, state management, device APIs, and more.
  • Native performance: Optimized bridge ensures smooth animations and interactions.

Analogy: Think of React Native as a universal translator: you write in JavaScript/React, and it speaks “native” to each mobile OS.

Prerequisites: What You’ll Need

Before scaffolding your project, ensure you have:

  1. Node.js & npm (or Yarn)
    • Recommended Node version: ≥14.x
  2. Watchman (macOS only)
    • Monitors file changes for faster rebuilds
  3. Android Studio (for Android emulator)
    • Android SDK, Virtual Device Manager
  4. Xcode (for iOS simulator; macOS only)
    • Command-line tools, simulators
  5. A Code Editor
    • VS Code, WebStorm, or your favorite IDE

Pro Tip: Use nvm to manage Node versions if you switch between projects.

Step 1: Installing the React Native CLI

React Native offers two main workflows: the React Native CLI for full native-code control, and Expo CLI for an abstracted, OTA-friendly environment. For maximum flexibility, we’ll use the React Native CLI.

  1. Install CLI globally bashCopyEditnpm install -g react-native-cli
  2. Verify installation bashCopyEditreact-native --version # Expected output: react-native-cli: X.Y.Z

Expert Insight: Installing the CLI globally keeps your system tools up to date. You can also use npx react-native to always run the latest version without global installs.

Step 2: Scaffold Your New Project

With the CLI installed, create your project:

bashCopyEditreact-native init MyFirstApp
  • MyFirstApp: Your project’s folder name and the app’s default display name.
  • --template (optional): Specify a template, e.g., --template react-native-template-typescript for TypeScript support.
bashCopyEditreact-native init MyFirstApp --template react-native-template-typescript

This command:

  1. Fetches the latest React Native package from npm.
  2. Generates the directory structure, native code, and JS boilerplate.
  3. Installs dependencies in node_modules/.

Step 3: Exploring the Project Structure

Open MyFirstApp/ in your editor. The key folders and files:

graphqlCopyEditMyFirstApp/
├── android/           # Native Android code & Gradle scripts
├── ios/               # Native iOS code & Xcode project
├── node_modules/      # npm dependencies
├── src/               # (optional) your source code folder
├── App.js             # Entry point; your root component
├── index.js           # App registration & AppRegistry
├── package.json       # Project metadata & scripts
└── babel.config.js    # Babel compiler settings
  • App.js: Renders your app’s root component.
  • index.js: Registers the root component with React Native.
  • Native folders (android/, ios/): Only dive in if you need custom native modules or configuration.

Best Practice: Create a src/ directory for your JavaScript files (components, screens, utils) and update import paths in index.js:

jsCopyEdit// index.js
import {AppRegistry} from 'react-native';
import App from './src/App';
import {name as appName} from './app.json';

AppRegistry.registerComponent(appName, () => App);

Step 4: Running Your App on an Emulator or Device

Android

  1. Start an Android emulator via Android Studio or CLI: bashCopyEditemulator -avd Pixel_3_API_30
  2. Run the app bashCopyEditnpx react-native run-android

iOS (macOS only)

  1. Install CocoaPods dependencies bashCopyEditcd ios && pod install && cd ..
  2. Run the app bashCopyEditnpx react-native run-ios
    • Adds --simulator="iPhone 12 Pro" to target a specific device.

Troubleshooting: If you encounter “Could not connect to development server,” ensure your Metro bundler is running:

bashCopyEditnpx react-native start

Step 5: Understanding Live Reload vs. Fast Refresh

React Native offers two modes to see your code changes instantly:

  • Live Reload: Reloads the entire app on file change—helpful for global state resets.
  • Fast Refresh: Preserves React state while injecting updated modules—ideal for tweaking UI.

Toggle in the in-app developer menu (shake device or press ⌘D / ⌘M).

Analogy: Live Reload is like rebooting your computer to install updates; Fast Refresh is like hot-swapping a component without shutting down.

Step 6: Customizing Your Starter Template

Open App.js (or src/App.js) and replace the boilerplate with a simple welcome screen:

jsxCopyEditimport React from 'react';
import { SafeAreaView, StyleSheet, Text, StatusBar } from 'react-native';

const App = () => (
  <>
    <StatusBar barStyle="dark-content" />
    <SafeAreaView style={styles.container}>
      <Text style={styles.title}>Welcome to My First React Native App!</Text>
    </SafeAreaView>
  </>
);

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#f0f0f0',
  },
  title: {
    fontSize: 24,
    fontWeight: '600',
    color: '#333',
  },
});

export default App;
  • SafeAreaView ensures content isn’t obscured on devices with notches.
  • StyleSheet.create provides a performant way to define styles.

Pro Tip: Organize styles in a separate styles/ folder if they grow large, or adopt libraries like Styled Components for scoped styling.

Step 7: Version Control and Dependency Management

  • Initialize Git bashCopyEditgit init git add . git commit -m "Initial scaffold of React Native project"
  • Use .gitignore (auto-generated) to exclude node_modules/, build artifacts, and .idea/ settings.
  • Lock dependencies by committing package-lock.json or yarn.lock—ensures consistent installs across your team.

Expert Insight: Pin React Native’s major version in package.json (e.g., "react-native": "0.68.x") to avoid unexpected breaking changes when you run npm update.

Conclusion

Scaffolding a new React Native project is a breeze with the React Native CLI. By installing the CLI, running react-native init, and understanding the generated directory structure, you can be up and running on both Android and iOS in minutes. Leverage Live Reload and Fast Refresh for rapid iteration, customize your starter template, and maintain best practices with version control and dependency locking. With this foundation in place, you’re ready to build out screens, integrate APIs, and deliver engaging mobile experiences. Happy coding!

Let's connect on TikTok

Join our newsletter to stay updated

Sydney Based Software Solutions Professional who is crafting exceptional systems and applications to solve a diverse range of problems for the past 10 years.

Share the Post

Related Posts