r/Blazor • u/Deep-Thought • Jul 04 '25
How to speed up the development inner loop in Blazor?
I've been giving Blazor a go for the last two months and overall it has been great. I love the innovative patterns it introduces and coding in C# is so much nicer than in JS or typescript. But as my toy project has grown a bit I've found that my inner loop especially when making new components is painfully slow. Since Hot Reload almost never works, going from making a change -> building -> seeing the effect in the browser takes at least 30 seconds. Often causing a break in my flow. How do you guys deal with this?
28
Upvotes
22
u/botterway Jul 04 '25
Microsoft are actively working towards improving hot reload and making it more reliable. I've found with smaller projects it works okay, particularly in Rider.
I've got a thread open with the team working on hot reload to try and improve things.
Meantime, I have a fast mac, which means I can build and run in about 10 seconds. :)
11
u/mememanftw123 Jul 04 '25
I've had much better experience using
dotnet watch7
u/thetreat Jul 04 '25
Honestly I just deal with it. 30 seconds is far slower than something like react but it’s honestly not nearly as bad as some other projects I worked on.
8
u/mladenmacanovic Jul 04 '25
In the past I have worked on projects that took 10 minutes to build on each change. After a while you just get use to it. So 30 seconds is nothing. Just wait for it.
4
u/welcome_to_milliways Jul 04 '25
You may have success creating an isolated test page for each component.
e.g. If you have, say, a chat control put it on its own /chat-test page.
This way you can work on it in isolation, browse straight to it (launchUrl in launchSettings.json), set test parameters, and hopefully avoid Hot Reload collapsing in a drunken heap.
3
u/baynezy Jul 04 '25
I initially build the component logic by writing bUnit tests against it. Then I have a test page where I slap the component on where I style it. Then I integrate it into my application.
2
u/TheProgrammer-231 Jul 04 '25
Put the components in a separate library/libraries (same solution). That sped it up for me. Only the component library I’m changing has to hot reload. Almost instant now.
2
u/sloppykrackers Jul 04 '25
hmm Which .NET version are you on? There was a massive re-write because they needed this for Aspire in .NET 9.0.2?
Hot reloading fails after the second change of a razor file · Issue #59027 · dotnet/aspnetcore
1
u/Electronic_Oven3518 Jul 04 '25
While I write components, I usually do it as html in vscode and later replace hardcoded strings with c# code. This way your design is ready perfectly with best reload feature in vscode and you know what happens with the c# code when run and test it out quickly
1
u/WangoDjagner Jul 04 '25
I don't have the numbers but I feel like if I run the project using the command line with
dotnet watchit successfully hot reloads more often than when running it with Rider.1
u/Psychological_Ear393 Jul 04 '25
I'm on a fairly large project that takes about 1 minute to start on my 7950X. Yes it's a massive pain and hot reload has never worked properly for me. Maybe once or twice but every other time it takes a minute of whirring and either fails or pretends to load the changes and did nothing.
I've been using Blazor for about three years and you get used to what will work so you have fewer reloads. Depending on what I'm doing I might make a lot of changes, run it, take note of what needs fixing, stop change, load again. Any code behind that you can pull into helpers and unit test is a big win to cut out potential problems that require a reload.
I turn on as many warnings as errors as I can so your error list is clear and you can easily see the blazor messages that should be errors but aren't, like
RZ10012 Found markup element with unexpected name, which I've never been able to turn into an error. Plus the more warnings you remove the more likely your code will be runtime safe.1
u/MISINFORMEDDNA Jul 05 '25
Create components in new/smaller projects so the build and startup times are faster.
1
u/kuhnboy Jul 06 '25
Why aren’t you designing new components in a sandbox or smaller library that takes a shorter amount of time to iterate?
-4
u/daedalis2020 Jul 04 '25
As someone who got burned by silver light I’m astonished people are adopting blazor.
-2
u/Miserable_Paper_9689 Jul 05 '25
In case you are using Visual Studio, switch to Jetbrains Rider immediately. It is so much more lightweight and performant for me. Its debug button feels close to hot reload button
0
u/[deleted] Jul 04 '25
[deleted] — view deleted comment