ReactJS.net 5.2

In 2020 ReactJS releases ReactJS.net 5.2. ReactJS.net makes it easier to use Facebook’s React and JSX from C# and others. It is an integration for ASP.NET and React. In ReactJS.NET 5.2 update a new feature called templates is introduced. Templates make getting started on a new project very easy. Now you can start a new project using React and server-side rendering.

dotnet new -i React.Template
dotnet new reactnet-webpack
dotnet run

For projects that don't need webpack reactnet-vanilla templates can be used.

The second feature is webpack asset manifest support. If you use hashes in filenames of generated assets this feature will help you. You can render the script and style tags automatically from the generated asset manifest when using Webpack and webpack-manifest-plugin. If you use filepattern '[name].[contenthash:8].js' webpack will remove files that look like the given below.

vendor.8faee7f5.js
Main-0c14766b.js

In server side configure the files with the syntax in which dist denotes the directory:

config.SetReactAppBuildPath("~/dist");

Call the below lines of code in the view.

@Html.ReactGetStylePaths() // in the document head next to other stylesheets

    @Html.ReactGetScriptPaths() // right before the body closing tag

Then define asset manifest format in the webpack config.