Writing Hello World code in React

Last Updated: February 22, 2021

In this tutorial we will see how we can get started with React by writing the Hello World application.

First create index.js in your folder and add the following code to it

const title = React.createElement(
	'h1',
    {id:'title',classname:'header'},
    'Hello World'
)

ReactDOM.render(
    title,
    document.getElementById('root')

)

Then you can create index.html file and define the root element

 
 

  
    
    
    
    title
  
  


Then I am going to open the terminal and change the directory where I have the files
I will run the following command to install httpster server

sudo npm install -g httpster

Once you install the server you can start the server with following command at terminal

httpster

When you start the server you will get following message
Starting HTTPster v1.0.3 on port 3333 from /Users/Dev/Documents/react

Now you can open the page http://localhost:3333/ and see the “Hello world” message