Here are just some quick thoughts about Blazor so far. I'll give you the tl;dr upfront because I'm cool.
If you're running a node, or other backend you should keep using whatever frontend framework you're currently using. You can check Blazor out and maybe start learning it but I wouldn't rewrite any of your stuff in Blazor.
The reason behind this is because IMO you lose some of the benefits of Blazor if you're not running a dotnet backend. One of my current pain points is that I'm running a React frontend and an Azure Function(C#) API.
I'm doing a lot of extra mapping. On the backend we have our Entities and DTOs. Then on the front end I'm taking data from the API and remapping it to fit the React frontend.
Just as a quick example we might have a Database Entity with First Name, Last Name, and Middle Initial. We don't need the Middle Initial on the frontend so our DTO only has First Name and Last Name. Those Two fields are sent to the frontend and I want to display them like this:
Lastname, Firstname
So what I do on the frontend is create a mapping function:
const mapFormValues = (values) => {
return `${values.Lastname}, ${values.Firstname}`
}
Now I could just pass down a field that is already a combination like FullName: "Myers, Tim"
but there are places where I still need to have just the first name or just the last name.
Its easier to combine values than it is to try and substring the whole value.
Another issue is that in C# our field names are Pascal Case
and in React our field names are camelCase
. You don't want to know how much time I've spend trying to figure out why something isn't rendering only to find out that the API is sending me, LastName
and I'm using lastName
.
So if you're running a C# backend you can directly benefit from using Blazor because you can share a model between the front end and backend.
I have a small app that I've written in React/Node/MongoDB and I am going to rewrite it in Blazor/ASP.NET to see what the actual pros and cons are.
Thanks for reading and that's all y'all.
Top comments (1)
Very interesting I am not that familiar with C# or Blazor so I found this to be quite a good introduction.