This repo contains boilerplate code for a React application with Node/Express serving the React App.
- React Application with simple routes
- Express application serving the HTML content
- Webpack/Babel configurations to bundle React app
Content is sliced using commits
The basic Node/Express app.
- Node app created with
npm init
- Added expressed using
npm i express
- Created
/public
folder with a sampleindex.html
file - Added
index.js
file that serves content in thepublic
folder - Added a script to start the Node app
Run npm run start
in the root directory and use your favourite browser to navigate to localhost:3000/
to see Hello World page
The basic React application
- Added React dependencies with
npm i react react-dom react-router-dom
- Created
app.js
to that contains the basic React app
N/A
Adding Webpack and Babel to transpile and bundle the React application into bundle.js
in /public
folder.
- Added Webpack and Babel dev dependencies
npm i --save-dev webpack webpack-cli @babel/core @babel/preset-env \@babel/preset-react babel-loader
- Added
webpack.config.js
file to bundle theapp.js
React app intobundle.js
in/public
- Added
.babelrc
- Added a
div
andscript
inindex.html
to integrate the React into the servedhtml
file
Run npm run start
and navigate to localhost:3000/
to see Content in the React application in the Hello World app
Define simple routes in the React application and allow dynamic routing thorugh Express
- Defined basic routing using
BrowserRouter, Switch and Route
inreact-router-dom
- Defined
get(*)
in Express server to allow dynamics routes
Run npm run start
and navigate to localhost:3000/
to see Content in the React application that allows navigations to /
/discover
and /dashboard
routes