React as a view engine
return this.ReactView
Server-side rendered and hydrated — no Web API, no Next.js, no SPA. Keep your controllers, services, and view models; replace only the view layer.
public IActionResult Detail(int id)
{
var model = _userService.GetUser(id); // unchanged domain code
return this.ReactView<UserProfile>(model); // React instead of a Razor view
}// Views/UserProfile.tsx
export default function UserProfile(props: UserDto) {
return <h1>{props.name}</h1>;
}Install both packages and you're ready:
dotnet add package ReactDotNetCore.AspNetCore
npm install @react-dotnetcore/runtime react react-domHead to Getting Started for a full project setup.