This repo is a basic example of hot reloading on both the server and the client using
Koa, React and Webpack based on the article Hot reload all the things! and the Koa example
To start the server run npm install
and npm start
.
- Open
localhost:3000
. A box with a button to fetch message from server will be rendered. - Click the button and see the app requests the message and renders it.
- Comment line
9
and uncomment line10
on./server/routes/api.js
. The server hot reloads. - Click the button and see the app fetches and renders the new message
THIS IS A HOT RELOADED MESSAGE
. - Modify anything on component
App
on file./common/App.js
. See the client gets hot reloaded too.
This was not possible in other hot reloading solutions but it is with this one. After having started the server just follow this steps:
- Make a request to
localhost:3000/hotroute
. See it just renders the App since the route does not exist yet and the server responds with the app by default. - Uncomment lines
2
and6
on./server/routes/index.js
. - Make a request again to
localhost:3000/hotroute
. See that instead of rendering the App the server now responds with a json with the messageTHIS IS A HOT RELOADED ROUTE
.