Mumrich.SpaDevMiddleware
1.6.0
dotnet add package Mumrich.SpaDevMiddleware --version 1.6.0
NuGet\Install-Package Mumrich.SpaDevMiddleware -Version 1.6.0
<PackageReference Include="Mumrich.SpaDevMiddleware" Version="1.6.0" />
<PackageVersion Include="Mumrich.SpaDevMiddleware" Version="1.6.0" />
<PackageReference Include="Mumrich.SpaDevMiddleware" />
paket add Mumrich.SpaDevMiddleware --version 1.6.0
#r "nuget: Mumrich.SpaDevMiddleware, 1.6.0"
#:package Mumrich.SpaDevMiddleware@1.6.0
#addin nuget:?package=Mumrich.SpaDevMiddleware&version=1.6.0
#tool nuget:?package=Mumrich.SpaDevMiddleware&version=1.6.0
Mumrich.SpaDevMiddleware
A .NET Middleware for ASP.NET Core that automatically integrates (multiple) Single-Page-Apps in a .NET-Webhost.
- Automatic node-package install (
npm/yarn/pnpm) - SPAs are automatically built upon (
dotnet publishtriggers thebuild-script inpackage.json) - Automatic path-mapping for the SPA by aid of the superb YARP
- SPA Hot-Reloading supported
- Custom-ENV-Variables can be passed to the Node-Instance via
appsettings.json - Usage of MSBUILD-Variables supported
Prerequisites
- .NET 10+
- Node.js (for development and build of the SPA)
- Either
npm,yarnorpnpmas Node-Package-Manager (depending on your choice)
Usage
Install the
Mumrich.SpaDevMiddlewareNuget-Package into your Web-Project.Modify the
csproj-file by adding the followingItemGroupand adjust the values accordingly:<ItemGroup> <SpaRoot Include="MyApp\"> <InstallCommand>npm install</InstallCommand> <BuildCommand>npm run build</BuildCommand> <BuildOutputPath>MyApp\dist\**</BuildOutputPath> </SpaRoot> </ItemGroup>Implement the
ISpaDevServerSettings-interface:public class AppSettings : ISpaDevServerSettings { public Dictionary<string, SpaSettings> SinglePageApps { get; set; } = new(); public string SpaRootPath { get; set; } = Directory.GetCurrentDirectory(); }Extend
appsettings.jsonwith a SPA-Config e.g.:{ "Logging": { "LogLevel": { "Default": "Information", "Microsoft.AspNetCore": "Warning" } }, "AllowedHosts": "*", "SinglePageApps": { "/": { "DevServerAddress": "http://localhost:3000/", "SpaRootPath": "MyApp", "NodePackageManager": "Npm" } } }Register Services and setup app e.g.:
using Mumrich.SpaDevMiddleware.Extensions; var builder = WebApplication.CreateBuilder(args); var appSettings = builder.Configuration.Get<AppSettings>(); builder.SetupSpaDevMiddleware(appSettings); var app = builder.Build(); app.MapSinglePageApps(appSettings); app.Run();When using hot-reloading, adapt your SPA-bundling-setup accordingly to accept the .NET-Webhost-Proxy on the correct Port. Custom-ENV-Variables can be passed via
appsettings.jsone.g for vite.config.ts:// https://vitejs.dev/config/ export default defineConfig({ plugins: [vue()], server: { host: true, port: 3000, strictPort: true, }, });Run the app (
dotnet run), navigate to the .NET-Web-host-Url and enjoy 👌!
Troubleshooting
- See the working Example in the
Mumrich.SpaDevMiddleware.Demo.WebHost-folder.
Credits
- Thx to aspnetcore-vueclimiddleware for providing insights how to handle console-output.
- Thx to AspNetCore.SpaYarp for providing idea and insights to use YARP.
- Thx to YARP for providing such a wonderfull tool.
License
This project is licensed under the MIT License - see the LICENSE.txt file for details.
Changelog
1.6
Features
- Improved startup: the middleware is waiting for the dev server to be ready (
UseWaitForDevServerMiddleware) - (Windows only) Improved Debug-Handling: the middleware is now registering a
ChildProcessTrackerthat automatically kills all child-processes of the dev-server-process when the .NET-Webhost is stopped. This prevents orphaned node-processes when stopping the .NET-Webhost via Debug-Stop (Shift+F5) in Visual Studio.
1.5
Features
- .NET 10 Support
Breaking Changes
- Obsolete method
RegisterSinglePageAppDevMiddlewareremoved
| Product | Versions 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. |
-
net10.0
- Akka.Hosting (>= 1.5.60)
- Mumrich.AkkaExt (>= 1.2.1)
- Mumrich.HelpersAndExtensions (>= 1.0.0)
- Mumrich.SpaDevMiddleware.Domain (>= 1.6.0)
- Yarp.ReverseProxy (>= 2.3.0)
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.6.0 | 94 | 2/14/2026 |
| 1.6.0-PullRequest7.14 | 39 | 2/14/2026 |
| 1.5.1 | 202 | 11/26/2025 |
| 1.5.1-PullRequest6.7 | 129 | 11/26/2025 |
| 1.5.1-PullRequest6.6 | 129 | 11/26/2025 |
| 1.5.1-PullRequest6.5 | 133 | 11/26/2025 |
| 1.4.1 | 1,016 | 5/1/2024 |
| 1.4.1-PullRequest0004.4 | 102 | 4/30/2024 |
| 1.4.1-PullRequest0004.3 | 94 | 4/30/2024 |
| 1.4.1-PullRequest0004.2 | 98 | 4/19/2024 |
| 1.4.0 | 566 | 12/12/2023 |
| 1.4.0-PullRequest0003.11 | 107 | 12/12/2023 |
| 1.4.0-PullRequest0003.10 | 103 | 12/12/2023 |
| 1.4.0-PullRequest0003.9 | 93 | 12/12/2023 |
| 1.4.0-PullRequest0003.8 | 107 | 12/12/2023 |
| 1.3.5 | 3,199 | 8/23/2023 |
| 1.3.5-PullRequest0002.1 | 138 | 8/23/2023 |
| 1.3.4 | 227 | 8/23/2023 |
| 1.3.3 | 334 | 3/24/2023 |