ASP.NET Core 3.1 with React - Server Side Rendering / Pre-rendering - two web services required?
After spending some time researching, that are the current options:
- Live on .NET Core 3.1 with the
NodeServices
with anobsolete
flag - Create separate projects for back-end (asp.net) and front-end (node.js)
- Fork/copy
NodeServices
and maintain by myself - Hope that a there will be a community driven fork of the
NodeServices
in the comming months before .NET 5 release were it will be removed eventually
I came across exactly the same problem. It took me a few weeks to create a new set up where frontend is separate from the backend.
I published the prepared boilerplate on GitHub and wrote a blog posts that explains how to enable server-side rendering with ASP.NET Core and React in details. The solution is a combination of CRA (Create React App), Storybook for CRA and a standard ASP.NET Core MVC template.
To make a long story short I built my custom asp-prerender-module and asp-prerender-data attributes. They communicate with an Express server based on Node.js to get the rendered HTML. Thereafter the HTML served to the browser gets "hydrated" with actions.