Two Popular Approaches

Prerequisites

How to Open Terminal in VSCode?

1. Using Create React App (CRA)

Step 1. Open Terminal in VSCode (see above) or simply use cmd.

Step 2. Cd to the folder where you wish to install an app.

Step 3. Run the CRA TypeScript template command.

npx create-react-app my-app --template typescript

Name of the app: my-app.

What is npx?

Once you execute the command, you should see the following output.

Command prompt

Step 4. Navigate into your project folder (my-app) in this case.

cd my-app

Step 5. Open the project in VSCode

code .

This opens the current folder in VSCode.

Step 6. Start the development server

npm start

CRA uses "npm start" because the "start script" in package.json runs Webpack Dev Server.

Step 7. Open http://localhost:3000 in your browser

You should see the React welcome page as shown below.

React App

2. Using Vite

Step 1. Open Terminal in VSCode or use the command.

Step 2. Run the Vite create command with the React + TS template.

npm create vite@latest my-app2 --template react-ts

What is npm create?

First, it will ask you to pick a UI framework; choose React here.

Select a framework

Then it will ask you to choose a language, choose TypeScript.

Select variant

Step 3. Navigate to your project folder

cd my-app2

Step 4. Open the project in VSCode

code .

Step 5. Install dependencies

npm install

Step 6. Start the dev server

npm run dev

Vite uses "npm run dev" because it's the custom script Vite sets in package.json to launch its ultra-fast dev server (powered by ESBuild).

Step 7. Open the URL shown in the terminal (usually http://localhost:5173)

You should see the React welcome page as follows.

Vite+React+TS

Why is npm install needed in Vite but not in CRA?

Feature CRA (create-react-app) Vite
Setup Command npx create-react-app ... npm create vite@latest ...
Dev Start Cmd npm start npm run dev
Dev Server Port 3000 Usually 5173
Build Tool Webpack ESBuild
Speed Slower Much Faster
TypeScript Supported via --template flag Supported via template flag

This might come in handy, too