Mumrich.SpaDevMiddleware
1.7.0
dotnet add package Mumrich.SpaDevMiddleware --version 1.7.0
NuGet\Install-Package Mumrich.SpaDevMiddleware -Version 1.7.0
<PackageReference Include="Mumrich.SpaDevMiddleware" Version="1.7.0" />
<PackageVersion Include="Mumrich.SpaDevMiddleware" Version="1.7.0" />
<PackageReference Include="Mumrich.SpaDevMiddleware" />
paket add Mumrich.SpaDevMiddleware --version 1.7.0
#r "nuget: Mumrich.SpaDevMiddleware, 1.7.0"
#:package Mumrich.SpaDevMiddleware@1.7.0
#addin nuget:?package=Mumrich.SpaDevMiddleware&version=1.7.0
#tool nuget:?package=Mumrich.SpaDevMiddleware&version=1.7.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.7
Features
- Added VitePlus support via
NodePackageManager.VitePlus(vpcommand). - Updated the Demo WebHost SPA example to a
vue-appsetup using VitePlus (vp install,vp run build). - Improved script execution consistency by invoking start scripts with
runin middleware command generation. - Updated build/dependency tooling (e.g. GitVersion
6.6.0, Akka1.5.62, Cake.Frosting6.1.0).
Breaking Changes
- Changed the default
NodePackageManagerfromYarntoNpmwhen not explicitly configured.
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.62)
- Mumrich.AkkaExt (>= 1.2.1)
- Mumrich.HelpersAndExtensions (>= 1.0.0)
- Mumrich.SpaDevMiddleware.Domain (>= 1.7.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.7.0 | 90 | 3/13/2026 |
| 1.7.0-PullRequest8.14 | 30 | 3/13/2026 |
| 1.6.0 | 105 | 2/14/2026 |
| 1.6.0-PullRequest7.14 | 43 | 2/14/2026 |
| 1.5.1 | 209 | 11/26/2025 |
| 1.5.1-PullRequest6.7 | 132 | 11/26/2025 |
| 1.5.1-PullRequest6.6 | 132 | 11/26/2025 |
| 1.5.1-PullRequest6.5 | 136 | 11/26/2025 |
| 1.4.1 | 1,050 | 5/1/2024 |
| 1.4.1-PullRequest0004.4 | 103 | 4/30/2024 |
| 1.4.1-PullRequest0004.3 | 95 | 4/30/2024 |
| 1.4.1-PullRequest0004.2 | 102 | 4/19/2024 |
| 1.4.0 | 569 | 12/12/2023 |
| 1.4.0-PullRequest0003.11 | 110 | 12/12/2023 |
| 1.4.0-PullRequest0003.10 | 106 | 12/12/2023 |
| 1.4.0-PullRequest0003.9 | 97 | 12/12/2023 |
| 1.4.0-PullRequest0003.8 | 109 | 12/12/2023 |
| 1.3.5 | 3,201 | 8/23/2023 |
| 1.3.4 | 229 | 8/23/2023 |