Install the latest version of nodejs from https://nodejs.org/ site.
Install create-react-app globally as below:
npm i -g create-react-app
Create the react-app in the folder of your choice on your local machine:
Modify the index.js file as shown below:
import React from "react"; import ReactDOM from "react-dom"; const element = <h1>Hello World</h1>; //console.log(element); ReactDOM.render(element, document.getElementById("root"));
Test the app on localhost:
Build the production optimized app:
npm run-script build
Copy the contents of the build folder and paste it on the Server at the location where you want to host it e.g. C:\data\testreactapp. Open IIS on the Server and add Website by right-clicking on Sites as shown below. Give it the required hostname or port to test it in browser e.g. http://helloworldapp.
The index.html file is already present at the Physical path created by the build which the IIS Server will look for as the default document.
Authentication can be Anonymous for testing purpose. However, please change as per your requirement. The AppPool by default runs with CLR 4.0 version and Integrated mode.
This approach is especially helpful when you have a back-end .Net Web API hosted on the same IIS Server to improve speed.