Getting Started on ASP.NET Core
This guide covers enabling server-side rendering and Babel compilation.
Category ASP.NET Core
Published: 28 May 2021
This guide covers enabling server-side rendering and Babel compilation. Getting started with ReactJS.NET on ASP.NET Core requires a few more steps compared to previous versions of ASP.NET and MVC. If you want a step-by-step guide on configuring a brand new site, see the ReactJS.NET tutorial for ASP.NET Core.
ReactJS.NET requires at least Visual Studio 2015 and ASP.NET Core 1.0, but has also been tested with VS 2017 and .NET Core 2.1.
Install the React.AspNet
package through NuGet. You will also need to install a JS engine to use (either V8 or ChakraCore are recommended). See the JSEngineSwitcher docs for more information. After these packages are installed, ReactJS.NET needs to be initialised in your Startup.cs
file (unfortunately this can not be done automatically like in previous versions of ASP.NET with WebActivator).
At the top of Startup.cs, add:
Directly above:
Add:
Directly above:
Add:
Finally, add this to Views\_ViewImports.cshtml
(or create it if it doesn't exist):
Reference JSX files directly in script tags:
You're done! You can now call Html.React
from within Razor files:
If you need support for non-Windows platforms, please see the OS X/Linux guide