BlazorCssLiveReload 2.0.0

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package BlazorCssLiveReload --version 2.0.0
                    
NuGet\Install-Package BlazorCssLiveReload -Version 2.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BlazorCssLiveReload" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BlazorCssLiveReload" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="BlazorCssLiveReload" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BlazorCssLiveReload --version 2.0.0
                    
#r "nuget: BlazorCssLiveReload, 2.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BlazorCssLiveReload@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BlazorCssLiveReload&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=BlazorCssLiveReload&version=2.0.0
                    
Install as a Cake Tool

CSS Live Reload for Blazor 🔥

Why this Exists

Blazor Hybrid apps are great, but the feedback loop is slow. Changing a CSS file normally requires:

  • Rebuilding the app
  • Restarting the WebView
  • Losing all UI state

BlazorCssLiveReload solves this with true CSS Hot Module Reloading. No rebuilds, no flicker, no WebView reloads.

Features

🔥 1. Real CSS Hot Module Reloading

Blazor Hybrid normally requires a rebuild for CSS updates. CSS changes are pushed directly into the WebView:

  • CSS updates apply instantly
  • No WebView reload or UI flicker
  • Supports plain CSS, .razor.css, and scoped styles

It feels closer to Flutter-style hot reload for styling.

🧵 2. Fully Compatible with .NET Hot Reload

Run your app using dotnet watch and both systems work together:

  • .NET Hot Reload updates C# code
  • BlazorCssLiveReload updates CSS

You get a smooth, continuous development loop.

🧩 3. Tailwind-First Workflow

Tailwind JIT regenerates CSS on every file change. This package is designed to fit directly into that workflow.

Perfect for modern frontend stacks.

Installation

1. Install the NuGet package

dotnet add package BlazorCssLiveReload

2. Add the JavaScript

Add the following script to your wwwroot/index.html:

<script src="_content/BlazorCssLiveReload/BlazorCssLiveReload.js"></script>

3. Register the service

Add this into MauiProgram.cs:

builder.Services.AddCssLiveReload(options =>
{
    options.ListenerPort = 5002;
    options.ListenerHost = "localhost";
    options.ServerUrl = "ws://localhost:5002/";
});

var app = builder.Build();

var server = app.Services.GetRequiredService<IEmbeddedCssServer>();
server.StartAsync(); 

var watcher = app.Services.GetRequiredService<CssFileWatcher>();
watcher.Start(FindProjectRoot(AppContext.BaseDirectory));
private static string FindProjectRoot(string startPath)
{
    var dir = new DirectoryInfo(startPath);

    while (dir != null && dir.Exists)
    {
        if (dir.GetFiles("*.csproj").Any())
            return dir.FullName;

        dir = dir.Parent;
    }

    throw new Exception("Cannot find project root (folder containing .csproj)");
}

4. Enable Live Reload in your MainLayout.razor

@inherits LayoutComponentBase
@inject BlazorCssLiveReload.CssLiveReloadService CssReload
@inject IJSRuntime JSRuntime

@Body

@code {
    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        if (firstRender)
        {
            await CssReload.ConnectAsync(JSRuntime);
        }
    }
}

Usage

Run your app using Hot Reload:

Windows:

dotnet watch -f net10.0-windows10.0.19041.0

Android:

dotnet watch -f net10.0-android

iOS:

dotnet watch -f net10.0-ios

MacCatalyst:

dotnet watch -f net10.0-maccatalyst

License

This project is licensed under the MIT License.

Contributing

Contributions are welcome!
Bug reports, feature requests, and discussions are open.

Support the Project

If this improves your DX, please consider starring the repo ❤️
Github: https://github.com/chicuong2k3/BlazorCssLiveReload

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated