MMIX.Blazor.Cookies 1.0.4

dotnet add package MMIX.Blazor.Cookies --version 1.0.4
                    
NuGet\Install-Package MMIX.Blazor.Cookies -Version 1.0.4
                    
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="MMIX.Blazor.Cookies" Version="1.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MMIX.Blazor.Cookies" Version="1.0.4" />
                    
Directory.Packages.props
<PackageReference Include="MMIX.Blazor.Cookies" />
                    
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 MMIX.Blazor.Cookies --version 1.0.4
                    
#r "nuget: MMIX.Blazor.Cookies, 1.0.4"
                    
#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 MMIX.Blazor.Cookies@1.0.4
                    
#: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=MMIX.Blazor.Cookies&version=1.0.4
                    
Install as a Cake Addin
#tool nuget:?package=MMIX.Blazor.Cookies&version=1.0.4
                    
Install as a Cake Tool

MMIX.Blazor.Cookies

ASP.NET-compatible cookie management for Blazor.

MMIX.Blazor.Cookies is a modern, .NET 8+ library for easy browser cookie management across all Blazor render modes. It is a highly modified fork of Bitzart's Blazor.Cookies project, optimized for better ASP.NET integration and full prerendering support.

  • Supports all Blazor United (.NET 8+) render modes: Static SSR, Interactive Server, Interactive WebAssembly, and Interactive Auto
  • Compatible with ASP.NET and Blazor Web App projects
  • Simple, dependency-injection-friendly API: inject ICookieService and manage cookies anywhere

Installation

Install the following package in your Blazor Server and/or Blazor Client project:

dotnet add package MMIX.Blazor.Cookies

Add this line to your Server and/or Client project program.cs:

builder.Services.AddCookieService();

Usage

Injecting the ICookieService in a class:

using MMIX.Blazor.Cookies;

public class Foo
{
    private readonly ICookieService _cookieService;

    public Foo(ICookieService cookieService)
    {
        _cookieService = cookieService;
    }

    public async Task SetCookie()
    {
        await _cookieService.SetAsync("hello", "world");
    }
}

Injecting the ICookieService in a Blazor component:

@using MMIX.Blazor.Cookies

@inject ICookieService CookieService

@code {

    public async Task SetCookie() {
        await CookieService.SetAsync("hello", "world");
    }

}

Supported Methods

The ICookieService interface provides the following methods:

Reading Cookies
// Retrieves a cookei by its name
Task<Cookie?> GetAsync(string name);

// Retrieves all cookies
Task<IEnumerable<Cookie>> GetAllAsync();
Setting Cookies
// Sets a cookie
Task SetAsync(string name, string value, CancellationToken cancellationToken = default);

// Sets a cookie with an expriation date
Task SetAsync(string name, string value, DateTime expires, CancellationToken cancellationToken = default);

// Sets a cookie with a CookieOptions object
Task SetAsync(string name, string value, CookieOptions cookieOptions, CancellationToken cancellationToken = default);

// Sets a cookie using a Cookie object
Task SetAsync(Cookie cookie, CancellationToken cancellationToken = default);

// Sets multiple cookies using a Cookie IEnumerable
Task SetAsync(IEnumerable<Cookie> cookies, CancellationToken cancellationToken = default);
Removing Cookies
// Removes a cookie by its name
Task RemoveAsync(string name, CancellationToken cancellationToken = default);

// Removes all cookies
public Task RemoveAllAsync(CancellationToken cancellationToken);

License

License

Credits to the original developers

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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
1.0.4 141 12/4/2025
1.0.3 180 11/5/2025
1.0.2 157 10/21/2025
1.0.1 164 10/19/2025
1.0.0 174 9/25/2025

- Fixed major bug that will fail install because it looks for non-existant MMIX.Blazor.Cookies.Patches package