Mumrich.SpaDevMiddleware
1.5.1
dotnet add package Mumrich.SpaDevMiddleware --version 1.5.1
NuGet\Install-Package Mumrich.SpaDevMiddleware -Version 1.5.1
<PackageReference Include="Mumrich.SpaDevMiddleware" Version="1.5.1" />
<PackageVersion Include="Mumrich.SpaDevMiddleware" Version="1.5.1" />
<PackageReference Include="Mumrich.SpaDevMiddleware" />
paket add Mumrich.SpaDevMiddleware --version 1.5.1
#r "nuget: Mumrich.SpaDevMiddleware, 1.5.1"
#:package Mumrich.SpaDevMiddleware@1.5.1
#addin nuget:?package=Mumrich.SpaDevMiddleware&version=1.5.1
#tool nuget:?package=Mumrich.SpaDevMiddleware&version=1.5.1
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
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.5
Features
- .NET 10 Support
Breaking Changes
- Obsolete method
RegisterSinglePageAppDevMiddlewareremoved
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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.55)
- Mumrich.AkkaExt (>= 1.2.1)
- Mumrich.HelpersAndExtensions (>= 1.0.0)
- Mumrich.SpaDevMiddleware.Domain (>= 1.5.1)
- Yarp.ReverseProxy (>= 2.3.0)
-
net8.0
- Akka.Hosting (>= 1.5.55)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Mumrich.AkkaExt (>= 1.2.1)
- Mumrich.HelpersAndExtensions (>= 1.0.0)
- Mumrich.SpaDevMiddleware.Domain (>= 1.5.1)
- Yarp.ReverseProxy (>= 2.3.0)
-
net9.0
- Akka.Hosting (>= 1.5.55)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Mumrich.AkkaExt (>= 1.2.1)
- Mumrich.HelpersAndExtensions (>= 1.0.0)
- Mumrich.SpaDevMiddleware.Domain (>= 1.5.1)
- 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.5.1 | 195 | 11/26/2025 |
| 1.5.1-PullRequest6.7 | 123 | 11/26/2025 |
| 1.5.1-PullRequest6.6 | 125 | 11/26/2025 |
| 1.5.1-PullRequest6.5 | 128 | 11/26/2025 |
| 1.4.1 | 967 | 5/1/2024 |
| 1.4.1-PullRequest0004.4 | 97 | 4/30/2024 |
| 1.4.1-PullRequest0004.3 | 89 | 4/30/2024 |
| 1.4.1-PullRequest0004.2 | 92 | 4/19/2024 |
| 1.4.0 | 559 | 12/12/2023 |
| 1.4.0-PullRequest0003.11 | 102 | 12/12/2023 |
| 1.4.0-PullRequest0003.10 | 98 | 12/12/2023 |
| 1.4.0-PullRequest0003.9 | 89 | 12/12/2023 |
| 1.4.0-PullRequest0003.8 | 103 | 12/12/2023 |
| 1.3.5 | 3,194 | 8/23/2023 |
| 1.3.5-PullRequest0002.1 | 134 | 8/23/2023 |
| 1.3.4 | 221 | 8/23/2023 |
| 1.3.3 | 329 | 3/24/2023 |
| 1.3.2 | 391 | 3/24/2023 |
| 1.3.1 | 315 | 3/24/2023 |
| 1.3.0-alpha.10 | 219 | 9/1/2022 |
| 1.3.0-alpha.6 | 209 | 9/1/2022 |
| 1.3.0-alpha.5 | 207 | 9/1/2022 |
| 1.2.1 | 427 | 1/12/2023 |
| 1.2.1-PullRequest0012.21 | 201 | 1/12/2023 |
| 1.2.0 | 2,324 | 10/5/2022 |
| 1.2.0-PullRequest0010.13 | 184 | 10/5/2022 |
| 1.2.0-PullRequest0009.13 | 182 | 10/5/2022 |
| 1.2.0-PullRequest0009.2 | 187 | 10/5/2022 |
| 1.1.2 | 589 | 9/28/2022 |
| 1.1.2-PullRequest0008.6 | 226 | 9/28/2022 |
| 1.1.2-PullRequest0008.5 | 219 | 9/28/2022 |
| 1.1.1 | 581 | 9/28/2022 |
| 1.1.0 | 582 | 9/28/2022 |
| 1.1.0-PullRequest0007.8 | 248 | 9/28/2022 |
| 1.0.5-PullRequest0007.7 | 261 | 9/28/2022 |
| 1.0.5-PullRequest0007.6 | 251 | 9/28/2022 |
| 1.0.5-PullRequest0006.1 | 216 | 7/14/2022 |
| 1.0.4 | 593 | 7/14/2022 |
| 1.0.4-PullRequest0006.3 | 221 | 7/14/2022 |
| 1.0.4-PullRequest0005.1 | 237 | 5/6/2022 |
| 1.0.3 | 584 | 5/6/2022 |
| 1.0.2 | 654 | 4/19/2022 |
| 1.0.0 | 572 | 4/19/2022 |
| 0.1.62 | 586 | 4/19/2022 |
| 0.1.62-PullRequest0004.3 | 230 | 4/19/2022 |
| 0.1.61 | 557 | 4/10/2022 |
| 0.1.60 | 557 | 4/10/2022 |
| 0.1.59 | 590 | 3/2/2022 |
| 0.1.54 | 584 | 3/1/2022 |
| 0.1.53 | 586 | 3/1/2022 |
| 0.1.52 | 587 | 3/1/2022 |
| 0.1.51 | 578 | 3/1/2022 |
| 0.1.50 | 580 | 3/1/2022 |
| 0.1.49 | 566 | 3/1/2022 |
| 0.1.48 | 583 | 3/1/2022 |
| 0.1.48-PullRequest0003.8 | 237 | 3/1/2022 |
| 0.1.47 | 596 | 2/24/2022 |
| 0.1.47-PullRequest0002.6 | 261 | 2/24/2022 |
| 0.1.46 | 587 | 2/23/2022 |
| 0.1.40-experimental.27 | 253 | 2/23/2022 |