In this article I will explain a simple tutorial with an example, how to create a simple ReactJS Hello World example in ASP.Net Core MVC.
This article will cover all the aspects such as Installing Packages, Integrating and Configuring ReactJS and finally creating a simple Hello World example in ASP.Net Core MVC.
Software Information
This article makes use of Visual Studio 2019, MVC Core and .Net Core 3.0.
Installing ReactJS Packages from Nuget
You will need to install the following packages from Nuget. In the Package Manager Console window, type the following commands (one by one) and press Enter key and the packages will start installing.
1. React.AspNet
Install-Package React.AspNet -Version 5.2.12
2. JavaScriptEngineSwitcher.V8
Install-Package JavaScriptEngineSwitcher.V8 -Version 3.18.1
3. JavaScriptEngineSwitcher.Extensions.MsDependencyInjection
Install-Package JavaScriptEngineSwitcher.Extensions.MsDependencyInjection -Version 3.3.0
Install-Package -Version 7.2.5
Adding ReactJS JSX file
Now in the Scripts Folder (create if not present) inside the wwwroot folder of the project, add a File of type TypeScript JSX File as shown below.
ASP.Net Core: ReactJS Hello World Example
Once added, rename the File extension TSX to JSX.
ASP.Net Core: ReactJS Hello World Example
Once the File is added, the following code needs to be added to the file.
Here a class HelloWorld is created which extends ReactJS Component.
The render function returns an HTML Header element (H1) with a message in it.
Finally, the ReactDOM.render function, render’s the class in a HTML DIV with ID dvMessage.
class HelloWorld extends React.Component {
    render() {
        return (<h1>My First ReactJS Core App!</h1>);
    <HelloWorld />,
Configuring ReactJS in Startup.cs class
The first step is to configure the JSON Serializer settings in the Startup.cs file.
Open the Startup.cs class from the Solution Explorer window.
ASP.Net Core: ReactJS Hello World Example
Once the Class is added, the following code needs to be added to the class.
ConfigureServices method
Inside the ConfigureServices method, first an IHttpContextAccessor is added to the services, so that static files (HelloWorld.jsx) can be accessed.
Note: For more details about using IHttpContextAccessor, please refer my article Using HttpContext in ASP.Net Core.
Then, React and JsEngineSwitcher is added and the Default Engine is set to V8JsEngine.
Finally, MVC is added and the compatibility is set to .Net Core 3.0.
Configure method
Inside the Configure method, the UseReact function is called and the HelloWorld.jsx file is added.
Finally, the UseStaticFiles method is called so that the Static files inside wwwroot folder can be accessed.
Note: For more details about using Static Files, please refer my article Static Files (Images, CSS and JS files) in ASP.Net Core.
using React.AspNet;
using JavaScriptEngineSwitcher.V8;
using JavaScriptEngineSwitcher.Extensions.MsDependencyInjection;
namespace ReactJS_MVC_Core
    public class Startup
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit
        public void ConfigureServices(IServiceCollection services)
            //Add IHttpContextAccessor for accessing Static Files.
            services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
            //Add React.
            //Add JsEngineSwitcher V8.
            services.AddJsEngineSwitcher(options => options.DefaultEngineName = V8JsEngine.EngineName).AddV8();
            //Add MVC.
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
            if (env.IsDevelopment())
            app.UseEndpoints(endpoints =>
                endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
            //Add the ReactJS File.
            app.UseReact(config =>
The Controller consists of following Action methods.
Action method for handling GET operation
Inside this Action method, simply the View is returned.
public class HomeController : Controller
    public IActionResult Index()
        return View();
The View consists of an HTML DIV dvMessage inside which the message from the ReactJS will be displayed.
Then the following necessary JS files for ReactJS application are inherited.
1. react.development.js
2. react-dom.development.js
Finally, the HelloWorld.jsx file is inherited.
    Layout = null;
<!DOCTYPE html>
    <meta name="viewport" content="width=device-width" />
    <div id="dvMessage"></div>
    <script src=""></script>
    <script src=""></script>
    <script src=""></script>
    <script src="@Url.Content("~/Scripts/HelloWorld.jsx")"></script>
That’s it and the application is ready to run.
ASP.Net Core: ReactJS Hello World Example