Loading

Quipoin Menu

Learn • Practice • Grow

react / Create React App Setup
tutorial

Create React App Setup

Imagine you want to bake a cake. You could grow the wheat, milk the cow, and build an oven from scratch. Or, you could buy a cake mix box that already has the flour, sugar, and instructions ready. You just add eggs and water. `create-react-app` is that cake mix box for React developers.

What is Create React App?

Create React App (CRA) is an officially supported tool from the React team that sets up a modern React application with zero configuration. It handles all the complex build tooling—like Babel (for JSX transformation), Webpack (for bundling), and a development server—so you can focus on writing code, not configuring tools.

Think of Create React App as the official 'React starter kit'. It gives you a complete, pre-configured environment to start building React apps immediately.

Why Use Create React App?

  • Zero Configuration: No need to set up Webpack, Babel, or other tools. Everything works out of the box.
  • Best Practices Built-In: It includes features like hot reloading (your page updates as you code), optimized production builds, and linting.
  • Focus on Code: You can start writing React components immediately without wasting time on tooling.
  • Official and Maintained: It's the recommended way to create new React single-page applications.

Prerequisites

Before you can use Create React App, you need two things installed on your computer:

  • Node.js: JavaScript runtime that lets you run JavaScript outside the browser. Download from nodejs.org.
  • npm (Node Package Manager): Comes automatically with Node.js. It's used to install and manage JavaScript packages.

How to Create a New React App

Open your terminal or command prompt and run one of these commands:

Using npx (recommended):
npx create-react-app my-first-react-app

Using npm:
npm init react-app my-first-react-app

Using yarn:
yarn create react-app my-first-react-app

Replace `my-first-react-app` with whatever you want to name your project. This command will create a new folder with that name, install all necessary dependencies, and set up the project structure.

Running Your App

After the installation finishes, navigate into your project folder and start the development server:
cd my-first-react-app
npm start

This will start a development server and automatically open your new React app in the browser at `http://localhost:3000`. The page will automatically reload if you make changes to the code.

What You Get

After running CRA, your project folder will look something like this:
my-first-react-app/
node_modules/
public/
index.html
favicon.ico
src/
App.js
App.css
index.js
index.css
package.json
README.md

Important Files:
  • public/index.html: The single HTML file that serves your entire React app.
  • src/index.js: The JavaScript entry point. It renders your root component (usually `App`) into the DOM.
  • src/App.js: Your main app component. This is where you'll start building.

Example: Your First React Component

Open `src/App.js` and you'll see something like this:
import logo from './logo.svg';
import './App.css';

function App() {
  return (
    <div className="App">
      <header className="App-header">
        <img src={logo} className="App-logo" alt="logo" />
        <p>
          Edit <code>src/App.js</code> and save to reload.
        </p>
      </header>
    </div>
  );
}

export default App;

You can edit this file, save it, and see the changes live in your browser.

Building for Production

When your app is ready to be deployed, run:
npm run build

This creates an optimized `build` folder with minified, bundled files ready to be uploaded to any static hosting service.

Two Minute Drill

  • Create React App (CRA) is the official, zero-configuration tool to set up a new React project.
  • It handles all build tooling (Babel, Webpack, dev server) so you can focus on coding.
  • Prerequisites: Node.js and npm installed.
  • Create a new app: `npx create-react-app my-app`.
  • Start development: `cd my-app` then `npm start` – app runs at `localhost:3000` with hot reloading.
  • Build for production: `npm run build` creates optimized files in the `build` folder.

Need more clarification?

Drop us an email at career@quipoinfotech.com