React Component Nesting and Reusability Explained – A Beginner's Guide 2026

Image
1. Introduction to React Component Nesting and Reusability React JS is a popular JavaScript library used to create interactive and user-friendly web applications. One of the most useful concepts in React development is component-based architecture. Instead of writing an entire website inside one large file, developers divide the user interface into smaller and manageable parts called components. Two important concepts in this approach are component nesting and component reusability. Component nesting means placing one React component inside another component to build a complete user interface. For example, a website page may contain a header, navigation bar, sidebar, content section, and footer. Each section can be developed as a separate component and combined inside a main component. Component reusability means creating a component once and using it multiple times in different parts of an application. For example, the same button, product card, or navigation menu can be reused withou...

Create React App Using Vite: Complete Beginner's Guide (2026)

How to Create a React App Using Vite: Step-by-Step Tutorial

Create React App Using Vite


1. Introduction

React.js is a popular JavaScript library used to create interactive and modern websites. Many beginners want to learn React but feel confused about how to install it and start their first project. Before writing React code, we need a proper development environment.

In this tutorial, you will learn how to create a React app using Vite from the beginning. We will cover the basic requirements, installation process, project structure, important features, advantages, disadvantages and practical code examples.

2. What Is React.js?

React.js is an open-source JavaScript library used to build user interfaces, especially for websites and web applications. It was originally developed at Facebook (now Meta) to make it easier to manage complex and interactive website interfaces.

React allows developers to divide a website into smaller parts called components. Each component can manage its own structure and behaviour. For example login , navigation bar ,website header form and footer can all be created as separate components.

One important concept in React is JSX. JSX allows developers to write HTML-like syntax inside JavaScript code. It makes the user interface easier to understand and maintain.

React also provides features such as reusable components, props, state and event handling. These features help developers create applications with less repeated code.

For example, when a user clicks a button, React can update the required part of the interface without manually changing the entire webpage.

React is useful for beginners as well as professional developers because it supports small projects and large applications.

3.1 Check Node.js and npm

Before creating a React application, install Node.js on your computer.

Open Command Prompt or the terminal and run:

node -v

To check npm, run:

npm -v

If both commands display version numbers, Node.js and npm are available.

3.2 Create a React Project Using Vite

First, open your terminal and execute this command:

npm create vite@latest my-react-app -- --template react

What does this command mean?

  • npm: Node Package Manager.
  • create: Runs a project creation tool.
  • vite@latest: Uses the latest published Vite scaffolding tool.
  • my-react-app: Name of your new project folder.
  • --template react: Selects the React JavaScript template.

3.3 Install Project Dependencies

Move into your project folder:

cd my-react-app

Install the required packages:

npm install

This command downloads the dependencies needed to run your React application.

3.4 Start the Development Server

Now run:

npm run dev

Vite starts a local development server. Open the local URL displayed in your terminal, usually:

http://localhost:5173/

You should now see your React application running in your browser.

3.5 Create Your First React Component

Open the src/App.jsx file and replace its existing code with:

function App() {

  return (

    <div>

      <h1>Hello, React!</h1>

      <p>Welcome to my first React project.</p>

    </div>

  );

}

 export default App;

Explanation:

  • function App() creates a React component.
  • return() describes the user interface.
  • h1 displays the main heading.
  • p displays a paragraph.
  • export default App makes the component available to other files.

3.6 Create a React Button Using useState

Now create a simple counter application.

import { useState } from "react";

 function App() {

  const [count, setCount] = useState(0); 

  return (

    <div>

      <h1>React Counter</h1> 

      <h2>Count: {count}</h2> 

      <button onClick={() => setCount(count + 1)}>

        Increase

      </button>

    </div>

  );

} 

export default App;

Explanation:

  • useState is a React Hook used to manage component state.
  • count stores the current counter value.
  • setCount updates the counter.
  • The button's onClick event increases the value by one.
  • React displays the updated value automatically.

React installation and requirements

3.7 Build Your Project for Production

When your application is ready, run:

npm run build

Vite creates an optimized production version of your project in the dist folder.

To preview the production build locally, run:

npm run preview

Congratulations! You have created your first React application using Vite.

4. Frequently Asked Questions (FAQs)

Q1. What is Vite in React?

Vite is a frontend build tool used to create and develop React applications. It provides a development server and production build tools.

Q2. Is Vite better than Create React App?

Vite is a modern development tool that offers a fast development experience. Create React App has been deprecated, and React's documentation no longer recommends it for new applications.

Q3. Is Node.js required for React?

For a local React project created using Vite, Node.js is required to run the development tools and npm commands.

Q4. Is React free to use?

Yes. React is open-source software and can be used for personal, educational and commercial projects under its license.

Q5. Can beginners learn React?

Yes. Beginners can learn React after understanding basic HTML, CSS and JavaScript concepts.

Q6. What is the use of npm in React?

npm is a package manager used to install, update and manage the packages required by a React project.

Q7. What is the difference between React and Vite?

React is a JavaScript library for building user interfaces, whereas Vite is a development and build tool used to create and run frontend projects.

Q8. How do I run a React project?

Open the project folder in your terminal, run npm install and then execute npm run dev to start the development server.

Q9. What is JSX in React?

JSX is a syntax extension that allows developers to write HTML-like code inside JavaScript.

Q10. Can I use VS Code for React development?

Yes. Visual Studio Code is a popular code editor for creating, editing and managing React projects.

5. Conclusion

Creating a React application using Vite is a simple and practical way to begin learning modern frontend development. In this tutorial, we explored React.js, its history, important features, advantages, disadvantages and working process.

We also learned how to check Node.js and npm, create a React project, install dependencies, start the development server and write our first React components.

The best way to understand React is to practise regularly. Start with small projects such as a counter, calculator, to-do list or simple shopping page. As your knowledge improves, you can move towards more advanced applications.

Keep learning, keep practising and build your own projects with React!

Thank you for visiting Web Designing Theory. Keep learning and growing with us.

Visit our blog for more web development tutorials:

https://webdesigningtheory.blogspot.com/

Comments

Popular posts from this blog

CSS Text Color Explained with Syntax and HTML Examples

CSS Outline Offset Property with Practical Examples

Learn CSS text-decoration-color Property in Simple Words with Examples