Create a New React App – React (2024)

These docs are old and won’t be updated. Go to react.dev for the new React docs.

See Start a New React Project for the recommended ways to create an app.

Use an integrated toolchain for the best user and developer experience.

This page describes a few popular React toolchains which help with tasks like:

  • Scaling to many files and components.
  • Using third-party libraries from npm.
  • Detecting common mistakes early.
  • Live-editing CSS and JS in development.
  • Optimizing the output for production.

The toolchains recommended on this page don’t require configuration to get started.

If you don’t experience the problems described above or don’t feel comfortable using JavaScript tools yet, consider adding React as a plain <script> tag on an HTML page, optionally with JSX.

This is also the easiest way to integrate React into an existing website. You can always add a larger toolchain if you find it helpful!

Recommended Toolchains

The React team primarily recommends these solutions:

  • If you’re learning React or creating a new single-page app, use Create React App.
  • If you’re building a server-rendered website with Node.js, try Next.js.
  • If you’re building a static content-oriented website, try Gatsby.
  • If you’re building a component library or integrating with an existing codebase, try More Flexible Toolchains.

Create React App

Create React App is a comfortable environment for learning React, and is the best way to start building a new single-page application in React.

It sets up your development environment so that you can use the latest JavaScript features, provides a nice developer experience, and optimizes your app for production. You’ll need to have Node >= 14.0.0 and npm >= 5.6 on your machine. To create a project, run:

npx create-react-app my-appcd my-appnpm start

Note

npx on the first line is not a typo — it’s a package runner tool that comes with npm 5.2+.

Create React App doesn’t handle backend logic or databases; it just creates a frontend build pipeline, so you can use it with any backend you want. Under the hood, it uses Babel and webpack, but you don’t need to know anything about them.

When you’re ready to deploy to production, running npm run build will create an optimized build of your app in the build folder. You can learn more about Create React App from its README and the User Guide.

Next.js

Next.js is a popular and lightweight framework for static and server‑rendered applications built with React. It includes styling and routing solutions out of the box, and assumes that you’re using Node.js as the server environment.

Learn Next.js from its official guide.

Gatsby

Gatsby is the best way to create static websites with React. It lets you use React components, but outputs pre-rendered HTML and CSS to guarantee the fastest load time.

Learn Gatsby from its official guide and a gallery of starter kits.

More Flexible Toolchains

The following toolchains offer more flexibility and choice. We recommend them to more experienced users:

  • Neutrino combines the power of webpack with the simplicity of presets, and includes a preset for React apps and React components.
  • Nx is a toolkit for full-stack monorepo development, with built-in support for React, Next.js, Express, and more.
  • Parcel is a fast, zero configuration web application bundler that works with React.
  • Razzle is a server-rendering framework that doesn’t require any configuration, but offers more flexibility than Next.js.

A JavaScript build toolchain typically consists of:

  • A package manager, such as Yarn or npm. It lets you take advantage of a vast ecosystem of third-party packages, and easily install or update them.
  • A bundler, such as webpack or Parcel. It lets you write modular code and bundle it together into small packages to optimize load time.
  • A compiler such as Babel. It lets you write modern JavaScript code that still works in older browsers.

If you prefer to set up your own JavaScript toolchain from scratch, check out this guide that re-creates some of the Create React App functionality.

Don’t forget to ensure your custom toolchain is correctly set up for production.

Create a New React App – React (2024)

FAQs

How do I create a new app in react JS? ›

Steps to Build React App with Create React App
  1. Step 1: Install Create React App. ...
  2. Step 2: Overview of React App Structure. ...
  3. Step 3: Starting the React App Development Server. ...
  4. Step 4: Using the React Testing Library to Run Tests. ...
  5. Step 5: Modifying the Meta Data for the App. ...
  6. Step 6: Using Assets like Images.
Jun 16, 2024

How to create your own Create React App? ›

This is so that when we publish the template to npm, the create-react-app utility can find it.
  1. Create a template. json File. ...
  2. Initialize NPM. Open a terminal and go into the "cra-template-mui-moment” directory we created in step #1 and run the following command. ...
  3. Create a template directory. ...
  4. Publish to NPM. ...
  5. Useful Resources.
Jan 20, 2022

How do I start an already created React app? ›

How do I run an existing react app? To run an existing react app, clone or download the app's repository, navigate to the app's directory in the terminal, and run npm install to install dependencies. After that, execute npm start to run the app.

What is the command to create a React app? ›

Once the React installation is successful, we can create a new React project using create-react-app command. Here, I choose "reactproject" name for my project.

What is npm Create React App? ›

The create react app command allows us to create a development environment and install all necessary libraries for creating single-page applications using React. The CRA tool is used to set up a new React project quickly, providing a standard structure and configuration.

How do I create and deploy React app? ›

By following these steps, you can effectively deploy and maintain your React app for users to enjoy.
  1. Step 1: Create a React app. ...
  2. Step 2: Prepare the app for deployment. ...
  3. Step 3: Choose a hosting service. ...
  4. Step 4: Deploy the React app. ...
  5. Step 5: Test the React app. ...
  6. Step 6: Monitor performance. ...
  7. Step 7: Streamline future updates.
Aug 20, 2024

What is a better way to create a react app? ›

The React team primarily recommends these solutions:
  1. If you're learning React or creating a new single-page app, use Create React App.
  2. If you're building a server-rendered website with Node.js, try Next.js.
  3. If you're building a static content-oriented website, try Gatsby.

How do I create a React desktop app? ›

  1. Step 1: Create a React App or you can use vite. Open your terminal and run:npx create-react-app my-electron-app cd my-electron-app.
  2. Step 2: Install Electron. ...
  3. Step 3: Configure the Electron Entry Point. ...
  4. Step 4: Update Your package. ...
  5. Step 5: Run Your Electron App.
Mar 2, 2024

Does Create React App still work? ›

In 2023, the Create React App tool was deprecated, which means that it was no longer being maintained. Create React App has been the go-to way to make a new React project, but it's been dethroned by a number of different alternatives.

What is the fastest way to start a React app? ›

By starting with a framework, you can get started with React quickly, and avoid essentially building your own framework later.

How do I manually set up React app? ›

Step by Step
  1. Make sure node is installed in your system. Install Node. ...
  2. Create project folder and package. json. ...
  3. Install webpack dependencies. npm i --save-dev webpack webpack-cli webpack-dev-server. ...
  4. Install the Babel dependencies. ...
  5. Install required Linters and path. ...
  6. Install react and react-dom. ...
  7. Create index. ...
  8. Create App.

How do I create an old React app? ›

If you want to downgrade your current react version to previous version of react, Try These 5 Steps.
  1. You go to your folder file structure and delete both package-lock. json ( yarn. lock for yarn) file and node_modules file.
  2. After you go to your package.json file and change and edit these dependencies :
Oct 4, 2017

How do I create my own React app? ›

To use Create React App, we first need to open our terminal or command line on our computer. To create a new React project, we can use the tool npx , provided you have an npm version of at least 5.2.

How do I create a React app in Visual Studio? ›

Create your app
  1. In the Start window (choose File > Start Window to open), select Create a new project.
  2. Search for React in the search bar at the top and then select Standalone JavaScript React Project or Standalone TypeScript React Project, based on your preference.
  3. Give your project and solution a name.
May 23, 2024

How do I create a React app in my browser? ›

First of all , To run react js app in web browser, there is no need of internet. Open command prompt, Then go to folder where reactJs app is created in command prompt, Then go to in reactJs app in command prompt, Then run react app using this "npm start".

How do you create a React to do app? ›

Here's how you can do it:
  1. Create a React App: Open your terminal and navigate to your preferred directory. Run the following command to generate a new React app. ...
  2. Navigate to the Project Directory: Change your working directory to the “todo-app” folder: cd todo-app.
  3. Start the Development Server:
Oct 17, 2023

How do I create a new react app in the current folder? ›

After running the create-react-app command, your new React application will be created in a directory called my-app inside your current directory. Inside the my-app directory, you'll find the initial project structure and some files. The most important file is src/App. js , where you can start building your React app.

How to create a new file in ReactJS? ›

First, we need to install a library called file-saver . It's a simple library that enables us to generate files and trigger a download. To install it, open the command prompt in your ReactJS application directory and type npm install file-saver . Next, let's create a new file in our src directory.

Is there any other way to create react app? ›

Vite's simplicity, speed, and modern approach to web development make it probably the best spiritual successor and alternative to Create React App. Although its SSR support for React isn't the best, it's still workable thanks to plugins. Find out more about Vite in our tutorial.

Top Articles
Latest Posts
Article information

Author: Clemencia Bogisich Ret

Last Updated:

Views: 5391

Rating: 5 / 5 (80 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Clemencia Bogisich Ret

Birthday: 2001-07-17

Address: Suite 794 53887 Geri Spring, West Cristentown, KY 54855

Phone: +5934435460663

Job: Central Hospitality Director

Hobby: Yoga, Electronics, Rafting, Lockpicking, Inline skating, Puzzles, scrapbook

Introduction: My name is Clemencia Bogisich Ret, I am a super, outstanding, graceful, friendly, vast, comfortable, agreeable person who loves writing and wants to share my knowledge and understanding with you.