Creating React Application

Saurabh Pandey
3 min readOct 3, 2023

--

System Requirements

Before installing React, it’s important to ensure your system meets the necessary requirements. Here’s what you need:

  • Operating System: Windows 10 or 11, macOS 10.10, or Ubuntu 16 are recommended for the best compatibility and performance.
  • Hardware: At least 4GB of RAM and 10GB of storage space are required to run React and its associated tools smoothly.
  • A web browser and Internet access: A modern web browser (such as Google Chrome, Mozilla Firefox, or Microsoft Edge) and Internet access are necessary for viewing and testing your React applications.
  • Node.js and npm installed: As mentioned earlier, React relies on Node.js and npm for managing dependencies and running build scripts. Make sure you have both installed on your system.

Before installing React, you need to have Node.js and npm (Node Package Manager) installed on your system. If you haven’t already installed them, follow these steps:

  1. Visit the Node.js download page at: https://nodejs.org/en/download/
  2. Download the installer for your Windows system (either the LTS or Current version is fine, but the LTS version is recommended for most users)
  3. To install Node.js and npm, please run the installer and carefully follow the provided prompts.

Once npm and node is installed in your system use the below command to check the version

npm -v

Install Create React App

Create React App is a command-line tool that simplifies the process of setting up a new React project with a recommended project structure and configuration. To install Create React App globally, open a command prompt and run the following command:

npm install -g create-react-app

Create a New React Project

Now that you have the Create React App installed, you can use it to create a new React project. To do this, open a command prompt, go to the directory where you want the project to live, and run the following command:

create-react-app my-app

When you create a new React application using a tool like create-react-app (CRA), it comes with a default folder and file structure. Here’s a typical directory layout and a brief explanation for each:

my-app/
|-- node_modules/
|-- public/
| |-- index.html
| |-- favicon.ico
| |-- manifest.json
|-- src/
| |-- App.css
| |-- App.js
| |-- App.test.js
| |-- index.css
| |-- index.js
| |-- logo.svg
| |-- serviceWorker.js
| |-- setupTests.js
|-- .gitignore
|-- package.json
|-- README.md
|-- yarn.lock or package-lock.json
  1. components/: A directory where you would put all your React components. It’s common to split them into smaller, reusable pieces.
  2. assets/: Contains all the static assets like images, fonts, etc.
  3. utils/ or lib/: For utility functions and library code.
  4. views/ or pages/: For components that define entire views or pages.
  5. contexts/: If you’re using the React Context API, you might have a folder for context providers and hooks.
  6. hooks/: A directory for custom React hooks.
  7. routes/: If you’re using a router like React Router, you might have a folder for your route definitions and related components.
  8. styles/: For styles, especially if you’re using a CSS-in-JS solution, or if you want to organize your CSS modules or SASS files.

Remember, while these folder and naming conventions are common, they aren’t strict rules. The ideal structure for a React app often depends on the project’s scale and the developer’s or team’s preferences. As your app grows, it’s important to maintain a folder structure that helps you keep things organized and makes the codebase easy to navigate.

--

--

No responses yet