Questions And Answers

More Tutorials

React Boilerplate [React + Babel + Webpack]

react-starter project

About this Project

This is simple boilerplate project. This post will guide you to set up the environment for ReactJs + Webpack + Bable.

Lets get Started

we will need node package manager for fire up express server and manage dependencies throughout the project. if you are new to node package manager, you can check here. Note : Installing node package manager is require here.

Create a folder with suitable name and navigate into it from terminal or by GUI.Then go to terminal and type npm init this will create a package.json file, Nothing scary , it will ask you few question like name of your project ,version, description, entry point, git repository, author, license etc. Here entry point is important because node will initially look for it when you run the project. At the end it will ask you to verify the information you provide. You can type yes or modify it. Well that's it , our package.json file is ready.

Express server setup run npm install express@4 --save. This is all the dependencies we needed for this project.Here save flag is important, without it package.js file will not be updated. Main task of package.json is to store list of dependencies. It will add express version 4. Your package.json will look like "dependencies": { "express": "^4.13.4", ............. },

After complete download you can see there is node_modules folder and sub folder of our dependencies. Now on the root of project create new file server.js file. Now we are setting express server. I am going to past all the code and explain it later.

var express = require('express');
// Create our app
var app = express();
app.listen(3000, function () {
 console.log('Express server is using port:3000');

var express = require('express'); this will gave you the access of entire express api.

var app = express(); will call express library as function. app.use(); let the add the functionality to your express application. app.use(express.static('public')); will specify the folder name that will be expose in our web server. app.listen(port, function(){}) will here our port will be 3000 and function we are calling will verify that out web server is running properly. That's it express server is set up.

Now go to our project and create a new folder public and create index.html file. index.html is the default file for you application and Express server will look for this file. The index.html is simple html file which looks like

<!DOCTYPE html>
<meta charset="UTF-8"/>
 <h1>hello World</h1>

And go to the project path through the terminal and type node server.js. Then you will see * console.log('Express server is using port:3000');*.

Now go inside the public folder and create a new file app.jsx. JSX is a preprocessor step that adds XML syntax to your JavaScript.You can definitely use React without JSX but JSX makes React a lot more elegant. Here is the sample code for app.jsx

 <h1>Hello World!!!</h1>,

Now go to index.html and modify the code , it should looks like this

<!DOCTYPE html>
 <meta charset="UTF-8"/>
 <script src="
 <script src="">
 <script src=""> </script>
 <div id="app"></div>
 <script type="text/babel" src="app.jsx"></script>

With this in place you are all done, I hope you find it simple.


In this page (written and validated by ) you learned about React React Boilerplate . What's Next? If you are interested in completing React tutorial, your next topic will be learning about: React Setting up the project.

Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue:

Share On:

Mockstacks was launched to help beginners learn programming languages; the site is optimized with no Ads as, Ads might slow down the performance. We also don't track any personal information; we also don't collect any kind of data unless the user provided us a corrected information. Almost all examples have been tested. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. By using, you agree to have read and accepted our terms of use, cookies and privacy policy.