Blazor Server-Side: Render Component via JavaScript #13766
Labels
affected-few
This issue impacts only small number of customers
area-blazor
Includes: Blazor, Razor Components
Done
This issue has been fixed
enhancement
This issue represents an ask for new feature or an enhancement to an existing one
feature-blazor-server
severity-blocking
This label is used by an internal tool
Milestone
Is your feature request related to a problem? Please describe.
Currently if somebody has a big codebase in say react/angular (or other SPA framework) and want to migrate to Blazor Server-Side he would need to rewrite everything at once.
So it would be great if it would be possible to "render" a blazor component server-side via JavaScript methods into a dom element.
Describe the solution you'd like
Probably it would be good enough to have a javascript library published to npm that can call a blazor component by name.
I think the following points would need to be addressed aswell:
something like
await Html.RenderComponentAsync<CoursesList>(new { Courses = Model })
just for typescript with more options. Probably also needs some changes to blazor.I think at the moment it's possible to render to a razor view via
RenderMode.Server
and innerHTML the generated comment. (get the html page with the comment via ajax)actually
RenderComponentAsync
has a protocol that might be useful for the JavaScript part:https://github.com/aspnet/AspNetCore/blob/v3.0.0-preview9.19424.4/src/Components/Server/src/Circuits/ServerComponentDeserializer.cs
unfortunatly it needs DataProtection and I'm also unsure how useful Authentication/Authorization is on these components. Because I tried preview9 and the component will be rendered (but not work) as soon as the marker exists and the RazorPage/Mvc is AllowAnon.Additional context
Guess it would be a nice addition for .NET 5. And make it easier to test out Blazor when just creating a small set of components.
The text was updated successfully, but these errors were encountered: