Create React Hello Word App with TypeScript

Create React Hello Word App with TypeScript

In this article, we'll learn how to create a basic React web app from scratch. As a starting point, we'll build a simple project that displays "Hello World" on the screen. This is my very first article, and we'll take it step by step — gradually learning more and eventually building a fully functional website.

 


How to Create a New React App With TypeScript
Step 1: Create a New React Project with TypeScript

To create a new React app using TypeScript, run the following command in your terminal:
npx create-react-app my-app --template typescript

 

Let’s break it down:

    • npx: A tool that runs packages directly from the npm registry without installing them globally. It comes with Node.js.

    • create-react-app: A CLI tool that sets up a new React project with a sensible default configuration.

    • my-app: The name of your project folder. You can change this to whatever you want.

    • --template typescript: This tells CRA to use the TypeScript template instead of the default JavaScript one.


Step 2: Run Your App
      cd my-app
      npm start (Starts the React development server and Compiles your code and watches for changes.)
Your web app will open in the browser at http://localhost:3000/ (default port — it can be changed if needed).


Step 3: Open the Project in VS Code

Open the project folder in Visual Studio Code. Inside the src directory, locate the App.tsx file.

Update the JSX to display a "Hello World" message:


<div className="App">
      <header className="App-header">
        <img src={logo} className="App-logo" alt="logo" />
        <h1>Hello Word</h1>
      </header>
    </div>

You should now see "Hello World" displayed when you reload the app.
 
Great! we are done, it is our 1st app  ðŸ˜Š
In the next article, we’ll learn how to create and use components in React....

 


Thanks, for reading the blog, I hope it helps you. Please share this link on your social media accounts so that others can read our valuable content. Share your queries with our expert team and get Free Expert Advice for Your Business today.


About Writer

Ravinder Singh

Full Stack Developer
I have 12+ years of experience in commercial software development. I write this blog as a kind of knowledge base for myself. When I read about something interesting or learn anything I will write about it. I think when writing about a topic you concentrate more and therefore have better study results. The second reason why I write this blog is, that I love teaching and I hope that people find their way on here and can benefit from my content.

Hire me on Linkedin

My portfolio

Ravinder Singh Full Stack Developer