01 December 2024
Node.js and npm (Node Package Manager) are prerequisites for creating and running React applications.
node -v
npm -v
npm create vite@latest my-react-app --template react
- Replace `my-react-app` with your desired project name.
2. Navigate to the Project Directory:
cd my-react-app
Install Dependencies Run the following command to install all the dependencies
npm install
Run the Development Server Start the Vite development server to preview your app
npm run dev
http://localhost:5173
) where you can view your app in the browser.Once the setup is complete, your project folder will look like this:
my-react-app/
├── node_modules/ # Installed npm packages
├── public/ # Static assets (e.g., images, icons)
│ └── vite.svg # Default Vite logo
├── src/ # Source code of your application
│ ├── App.css # Styles for the App component
│ ├── App.jsx # Main React component
│ ├── main.jsx # Entry point for the application
│ └── index.css # Global styles
├── .gitignore # Files and folders to ignore in Git
├── package.json # Project metadata and dependencies
├── vite.config.js # Configuration file for Vite
└── README.md # Project documentation
Key Files and Folders:
src/main.jsx
: Entry point for your React app. It renders the root component (App.jsx
).src/App.jsx
: Default React component created by Vite. Customize this file to start building your app.public/
: Store static assets like images or fonts.package.json
: Manages dependencies, scripts, and project metadata.vite.config.js
: Customize the build tool's behavior (e.g., plugins, server options).