A hosting package that wraps endpoints with the Azure Static Web Apps emulator.
Install
| Product | Versions |
|---|---|
| .NET |
README
CommunityToolkit.Aspire.Hosting.Azure.StaticWebApps library
Provides extensions methods and resource definitions for the .NET Aspire AppHost to support running Azure Static Web Apps locally using the emulator using the Azure Static Web App CLI.
Getting Started
Install the package
In your AppHost project, install the package using the following command:
dotnet add package CommunityToolkit.Aspire.Hosting.Azure.StaticWebApps
Example usage
Then, in the Program.cs file of AppHost, define a frontend and backend resource (optional), then call AddSwaEmulator:
var builder = DistributedApplication.CreateBuilder(args);
// Define the API resource
var api = builder.AddProject<Projects.CommunityToolkit_Aspire_StaticWebApps_ApiApp>("api");
// Define the frontend resource
var web = builder
.AddNpmApp("web", Path.Combine("..", "CommunityToolkit.Aspire.StaticWebApps.WebApp"), "dev")
.WithHttpEndpoint(env: "PORT")
.WithExternalHttpEndpoints();
// Create a SWA emulator with the frontend and API resources
_ = builder
.AddSwaEmulator("swa")
.WithAppResource(web)
.WithApiResource(api);
builder.Build().Run();
Additional Information
https://learn.microsoft.com/dotnet/aspire/community-toolkit/hosting-azure-static-web-apps
Feedback & contributing
Changes from Previous Version
Adoption Assessment
A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.