Blazor Server Hot Reload

Blazor Server Hot Reload

I was working on the UI of a Blazor Server project the other day and had this cycle going on:

  1. Run my application without a debugger attached (CTRL + F5 in Visual Studio)

    Quick note on this, if you don’t do this you have to rebuild the project yourself before changes are visible.

  1. Make a few changes
  2. Reload browser to see the changes
  3. Repeat from step 2

I would love to see the browser refresh automatically after making a change, unfortunately that is not yet available in VS and third party (JavaScript) solutions I have tried didn’t actually work.

After a little search I found that Blazor has a public API, containing everything I needed to have the browser reload when it loses the SignalR connection.

This is a really simple implementation and it might not work for your use case. Let me know if this is helpful to you or if you have a better alternative!