Hello! Welcome to your second lesson.
In our last session, we explored the "why" behind React—its declarative nature and the efficiency of the Virtual DOM. We established the conceptual foundation for thinking in React.
Today, we transition from theory to practice. To start building React applications, you need a development environment. This lesson is dedicated to fulfilling our next learning outcome: setting up a React development environment with TypeScript using Vite. We'll cover the necessary tools, create a new project from scratch, and take a tour of the generated file structure. By the end, you'll have a fully functional local setup, ready for you to start writing code.
Given your software engineering background, you'll find the tooling aspect familiar, but we'll focus on the specifics of the modern React ecosystem.
The Tools of the Trade
Before we write a single line of React, we need a toolchain. In modern web development, we don't just write HTML, CSS, and JS files and open them in a browser. We use a set of tools that compile, bundle, and serve our code, providing a highly efficient development experience.
Our toolchain consists of:
- Node.js and npm: Node.js is a JavaScript runtime that allows us to run JavaScript outside the browser. We need it to run our build tools. npm (Node Package Manager) comes with Node.js and is used to manage project dependencies (like React itself).
- Vite: A next-generation frontend build tool. Vite provides an extremely fast development server and bundles your code for production. It's the engine that will power our development workflow.
- TypeScript: As requested, we are using TypeScript from the start. It's a superset of JavaScript that adds static types, helping us catch errors early and write more robust code.
Let's take a closer look at Vite, as it's the centerpiece of our setup.
Complete Guide to Setting Up React with TypeScript and Vite
To understand why we're using Vite and what problems it solves, this article provides an excellent overview.
Read the section 'What is Vite (as a Bundler)?'. Focus on understanding Vite's role as a build tool, its use of native ES modules for a fast development server (with HMR), and its use of a more traditional bundler (Rollup) for production builds.
In essence, Vite makes developing modern web apps a breeze. It handles the complex process of transforming our TypeScript and JSX code into something the browser can understand, and it does so with incredible speed.
Scaffolding Your First React Project
Now, let's get our hands dirty and create a new project.
First, ensure you have a recent version of Node.js (version 20.x or higher is recommended). You can check by running node -v in your terminal.
The following video provides a clear, step-by-step guide to creating your first React + TypeScript project using Vite's interactive command-line interface.
React Beginner Course 2025 (Vite, Tailwind CSS, TypeScript)
This video provides a clear, step-by-step guide to creating your first React + TypeScript project with Vite.
Watch from 02:42 to 07:12. This segment covers checking for Node.js, running the npm create vite@latest command, and selecting the correct options. Pay attention to the explanation of why TypeScript is a valuable tool to learn from the start.
When you run npm create vite@latest, you will be prompted to select a framework. Choose React as shown below.

Next, you will be asked to select a variant. Choose TypeScript + SWC. SWC is a super-fast compiler written in Rust that Vite uses under the hood to handle TypeScript and JSX transformations.
Installing Dependencies and Running the Server
Once the project files are created, there are two final commands to run:
npm install: This command reads thepackage.jsonfile in your new project and downloads all the required libraries (like React, ReactDOM, etc.) into anode_modulesfolder.npm run dev: This command starts the Vite development server.
Let's see this in action.
React Beginner Course 2025 (Vite, Tailwind CSS, TypeScript)
Now that the project files are created, let's install the necessary packages and start the development server.
Continue watching from 07:12 to 09:10. This part shows you how to navigate into the new project directory (cd your-project-name), run npm install, and finally npm run dev to see your app running in the browser.
If everything is successful, Vite will give you a local URL (usually http://localhost:5173). Open it in your browser, and you should see the default Vite + React landing page.

One of the key features you now have is Hot Module Replacement (HMR). Try opening src/App.tsx in your code editor, make a small text change, and save the file. You'll see the browser update instantly without a full page refresh. This is a core benefit of using a modern tool like Vite.
Understanding the Project Structure
With the application running, let's take a tour of the files and folders Vite created. A solid understanding of the project structure is crucial for knowing where to write your code and how the project is configured. Your background in software engineering will make this familiar, but it's good to see how a standard React project is laid out.
Complete Guide to Setting Up React with TypeScript and Vite
The article we looked at earlier provides an excellent, detailed breakdown of the generated project.
Please read the following sections: 'Folder Structure Overview': To get a high-level map of the project. 'Exploring the Project Files': To understand the roles of index.html, src/main.tsx, and src/App.tsx. 'Exploring the TypeScript Configuration': To see how TypeScript is configured for both the application code (tsconfig.app.json) and the Node.js-based tooling files (tsconfig.node.json). 'Exploring the Vite Configuration': To understand the vite.config.ts file and its role.
Let's recap the most important files:
index.html: The main HTML file for your app. Your entire React application will be mounted into the<div id="root"></div>element within this file.src/main.tsx: The entry point of your React application. This is where the connection is made between your React code and therootdiv inindex.html.src/App.tsx: The main "root" component of your application. This is where you'll start building your UI.vite.config.ts: Configuration for Vite. For now, it just includes the React plugin, but you can customize server ports, build settings, and more here.tsconfig.app.json: The TypeScript configuration specific to your application code in thesrcfolder. It contains rules for the compiler, such as enabling strict mode and defining how JSX should be handled.
Test your understanding!
You've just created a new project and have it running. You want to change the text on the main button from "count is 0" to "Click me: 0".
In which file would you make this change?
Show answer
You would make this change in src/App.tsx. This file contains the JSX code that defines the main component displayed on the page, including the button and its text.
Conclusion
Congratulations! You have successfully set up a modern, professional React development environment. This is a critical first step and the foundation for the rest of the course.
Let's review the key takeaways:
- Toolchain: Modern React development relies on a toolchain, with Node.js providing the runtime, npm managing packages, and Vite serving as our build tool and development server.
- Vite: We use Vite for its speed, simplicity, and features like Hot Module Replacement (HMR), which drastically improve the development experience.
- Project Scaffolding: The
npm create vite@latestcommand is a powerful and simple way to generate a new React project pre-configured with TypeScript. - File Structure: A standard Vite + React project has a clear structure, with
index.htmlas the host page,src/main.tsxas the app entry point, andsrc/App.tsxas the root component.
You are now fully equipped to start building. In our next lesson, we will finally dive into writing React code. We will explore JSX syntax and learn how it gets transformed into plain JavaScript, editing the App.tsx file you've just familiarized yourself with.