Skip to main content
net8.0

Blazor WebAssembly hosting support for Aspire.

Published
Sep 29, 2026
23d ago
Total Downloads
10.0K
10,040

Install

dotnet add package Aspire.Hosting.Blazor --version 13.6.0-preview.1.26479.8
ProductVersions
.NET
net8.0

README

Blazor hosting integration

Use this integration to model, configure, and orchestrate Blazor WebAssembly applications and a Blazor Gateway in an Aspire solution.

Getting started

Prerequisites

An existing Blazor WebAssembly project and any backend API projects it calls. The example below assumes the API exposes an endpoint named http.

Add the integration

From your AppHost directory, add the Aspire.Hosting.Blazor integration with the Aspire CLI:

aspire add Aspire.Hosting.Blazor

The Blazor gateway APIs are experimental. C# callers must opt in by suppressing ASPIREBLAZOR001, as shown below.

Usage example

Then, in the AppHost, add a Blazor WebAssembly resource, reference its backend API, and attach it to a gateway with either C# or TypeScript. For the C# example, add project references to ApiService and BlazorApp from the AppHost.

C#

#pragma warning disable ASPIREBLAZOR001

var builder = DistributedApplication.CreateBuilder(args);

var api = builder.AddProject<Projects.ApiService>("api");

var blazor = builder.AddBlazorWasmProject<Projects.BlazorApp>("web")
    .WithReference(api);

builder.AddBlazorGateway("gateway")
    .WithBlazorClientApp(blazor)
    .WithExternalHttpEndpoints();

builder.Build().Run();

#pragma warning restore ASPIREBLAZOR001

TypeScript

import { createBuilder } from "./.aspire/modules/aspire.mjs";

const builder = await createBuilder();

const api = await builder.addProject("api", "../ApiService/ApiService.csproj");

const blazor = await builder.addBlazorWasmProject("web", "../BlazorApp/BlazorApp.csproj")
    .withReference(await api.getEndpoint("http"));

await builder.addBlazorGateway("gateway")
    .withBlazorClientApp(blazor)
    .withExternalHttpEndpoints();

await builder.build().run();

The gateway serves the client app at /web/ and proxies requests to its referenced APIs. No separate gateway project is required.

Additional documentation

Feedback & contributing

https://github.com/microsoft/aspire

Changes from Previous Version

v13.5.4-preview.1.26464.4v13.6.0-preview.1.26479.8
Added Dependencies
Hex1b(net8.0)
MessagePack(net8.0)
Removed Dependencies

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

This version is marked prerelease. Validate its API and upgrade path before production use.Compatibility metadata lists 1 target framework; confirm the exact target used by your application.The published metadata declares 33 direct dependency entries across framework groups. Inspect the resolved dependency graph for your target framework.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.