# BlazorGatewayExtensions

- Kind: `class`
- Package: [Aspire.Hosting.Blazor](/reference/api/csharp/aspire.hosting.blazor.md)
- Version: `13.4.0-preview.1.26281.18`
- Namespace: `Aspire.Hosting`
- Target framework: `net8.0`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/becb48e2d61099e35ae336d527d3875e928d6594/src/Aspire.Hosting.Blazor/BlazorGatewayExtensions.cs)

Extension methods for adding Blazor WebAssembly apps and gateway resources.

## Definition

```csharp
namespace Aspire.Hosting;

public static class BlazorGatewayExtensions
{
    // ...
}
```

## Methods

- [AddBlazorGateway(IDistributedApplicationBuilder, string)](/reference/api/csharp/aspire.hosting.blazor/blazorgatewayextensions/methods.md#addblazorgateway-idistributedapplicationbuilder-string) : `IResourceBuilder<ProjectResource>` `extension` `ats export` -- Registers the built-in Blazor Gateway as a file-based C# app. The gateway is shipped as Gateway.cs alongside this library and launched via `AddCSharpApp`. No separate project is needed.
- [AddBlazorWasmApp(IDistributedApplicationBuilder, string, string)](/reference/api/csharp/aspire.hosting.blazor/blazorgatewayextensions/methods.md#addblazorwasmapp-idistributedapplicationbuilder-string-string) : `IResourceBuilder<BlazorWasmAppResource>` `extension` `ats export` -- Registers a Blazor WebAssembly project as a resource without launching it as a process. Prefer AddBlazorWasmProject<TProject> which uses IProjectMetadata for path discovery.
- [AddBlazorWasmProject(IDistributedApplicationBuilder, string)](/reference/api/csharp/aspire.hosting.blazor/blazorgatewayextensions/methods.md#addblazorwasmproject-idistributedapplicationbuilder-string) : `IResourceBuilder<BlazorWasmAppResource>` `extension` `ats ignored` -- Registers a Blazor WebAssembly project as a resource using the Aspire-generated IProjectMetadata type to discover the project path. The resource name becomes the URL path prefix (e.g., "store" → served at /store/). Use WithReference() to declare service dependencies.
- [WithBlazorClientApp(IResourceBuilder<ProjectResource>, IResourceBuilder<BlazorWasmAppResource>, string, string, bool)](/reference/api/csharp/aspire.hosting.blazor/blazorgatewayextensions/methods.md#withblazorclientapp-iresourcebuilder-projectresource-iresourcebuilder-blazorwasmappresource-string-string-bool) : `IResourceBuilder<ProjectResource>` `extension` `ats export` -- Attaches a Blazor WebAssembly app to the Gateway. The resource name is used as the URL path prefix (e.g., resource "store" → /store/). Service names are derived from WithReference() annotations on the WASM resource. Service references from the WASM app are automatically forwarded to the gateway so the gateway can resolve service endpoints for YARP proxying.
