Piral.Blazor.Orchestrator 0.3.0-preview.7581632115

This is a prerelease version of Piral.Blazor.Orchestrator.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Piral.Blazor.Orchestrator --version 0.3.0-preview.7581632115                
NuGet\Install-Package Piral.Blazor.Orchestrator -Version 0.3.0-preview.7581632115                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Piral.Blazor.Orchestrator" Version="0.3.0-preview.7581632115" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Piral.Blazor.Orchestrator --version 0.3.0-preview.7581632115                
#r "nuget: Piral.Blazor.Orchestrator, 0.3.0-preview.7581632115"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Piral.Blazor.Orchestrator as a Cake Addin
#addin nuget:?package=Piral.Blazor.Orchestrator&version=0.3.0-preview.7581632115&prerelease

// Install Piral.Blazor.Orchestrator as a Cake Tool
#tool nuget:?package=Piral.Blazor.Orchestrator&version=0.3.0-preview.7581632115&prerelease                

Piral Logo

Piral.Blazor.Orchestrator ยท GitHub License | GitHub Tag GitHub Issues Gitter Chat

The orchestration module for creating server-side micro frontends using Blazor.

Installation & Setup

For using Piral.Blazor.Server you'll need an ASP.NET Core project using Blazor (server).

You'll only need to add a single NuGet package to the project:

install-package Piral.Blazor.Orchestrator

With the package installed you'll need to configure your project to actually use Piral.Blazor.Orchestrator.

// Add DI services
builder.Services.AddMicrofrontends<MfDiscoveryLoaderService>();

// Configure container
builder.Host.UseMicrofrontendContainers();

// Use middleware
app.UseMicrofrontends();

A full example using these three integration points looks like:

using Piral.Blazor.Orchestrator;
using Piral.Blazor.Orchestrator.Loader;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
builder.Services.AddHttpClient();
builder.Services.AddSingleton<WeatherForecastService>();
builder.Services.AddMicrofrontends<MfDiscoveryLoaderService>();

builder.Host.UseMicrofrontendContainers();

var app = builder.Build();

app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseMicrofrontends();

app.MapBlazorHub();
app.MapFallbackToPage("/_Host");

app.Run();

With these in place you can modify your layout to integrate the necessary parts.

@inherits LayoutComponentBase

<PageTitle>Example</PageTitle>
<PageStyles />

<div class="page">
    <div class="sidebar">
        <NavMenu />
    </div>

    <main>
        <div class="top-row px-4">
            <a href="https://docs.microsoft.com/aspnet/" target="_blank">About</a>
        </div>

        <article class="content px-4">
            @Body
        </article>
    </main>
</div>

<PageScripts />

If you want to enable routing for your micro frontends (such that they can use the MapRoute feature) you should also exchange the Router in your App.razor with the MfRouter like so:

<MfRouter AppAssembly="@typeof(App).Assembly">
    <Found Context="routeData">
        <MfRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
        <FocusOnNavigate RouteData="@routeData" Selector="h1" />
    </Found>
    <NotFound>
        <PageTitle>Not found</PageTitle>
        <LayoutView Layout="@typeof(MainLayout)">
            <p role="alert">Sorry, there's nothing at this address.</p>
        </LayoutView>
    </NotFound>
</MfRouter>

The rest you can keep (or change) as you like.

Note: Using the MfRouteView in the code above is optional. We do recommend it, however, if you just keep on using RouteView then it would work, too.

Finally, remove the reference to any blazor.server.js script, i.e., transform your _host.cshtml to have no <script> tag such as:

@page "/"
@using Microsoft.AspNetCore.Components.Web
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <base href="~/" />
    <link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
    <link href="css/site.css" rel="stylesheet" />
    <link href="nne.server.app.styles.css" rel="stylesheet" />
    <link rel="icon" type="image/png" href="favicon.png"/>
    <component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />
</head>
<body>
    <component type="typeof(App)" render-mode="ServerPrerendered" />

    <div id="blazor-error-ui">
        <environment include="Development">
            An unhandled exception has occurred. See browser dev tools for details.
        </environment>
        <a href="" class="reload">Reload</a>
        <a class="dismiss">๐Ÿ—™</a>
    </div>
</body>
</html>

The script will be injected (and run) from the orchestrator.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
0.5.0-preview.9323268279 78 5/31/2024
0.5.0-preview.9024802187 58 5/9/2024
0.5.0-preview.8970923590 71 5/6/2024
0.5.0-preview.8961943566 49 5/5/2024
0.5.0-preview.8937540881 29 5/3/2024
0.5.0-preview.8924267614 32 5/2/2024
0.5.0-preview.8924038944 25 5/2/2024
0.5.0-preview.8919570786 41 5/2/2024
0.5.0-preview.8916013860 47 5/1/2024
0.5.0-preview.8870989656 52 4/28/2024
0.5.0-preview.8846899499 66 4/26/2024
0.5.0-preview.8831737080 61 4/25/2024
0.5.0-preview.8817031997 61 4/24/2024
0.5.0-preview.8785877670 60 4/22/2024
0.5.0-preview.8768228498 62 4/20/2024
0.5.0-preview.8766464948 57 4/20/2024
0.5.0-preview.8552466834 69 4/4/2024
0.5.0-preview.8538723932 160 4/3/2024
0.5.0-preview.8538694667 51 4/3/2024
0.5.0-preview.8489808898 66 3/30/2024
0.5.0-preview.8378016864 52 3/21/2024
0.5.0-preview.10938254736 56 9/19/2024
0.5.0-preview.10937840879 47 9/19/2024
0.5.0-preview.10937538276 49 9/19/2024
0.5.0-preview.10903389206 67 9/17/2024
0.5.0-preview.10301764169 66 8/8/2024
0.4.1 320 2/16/2024
0.4.1-preview.7933391150 70 2/16/2024
0.4.1-preview.7924227833 61 2/16/2024
0.4.1-preview.7923896542 62 2/16/2024
0.4.1-preview.7922609748 55 2/15/2024
0.4.1-preview.7922124111 57 2/15/2024
0.4.1-preview.7921989076 60 2/15/2024
0.4.1-preview.7917520828 63 2/15/2024
0.4.0 243 2/13/2024
0.4.0-preview.7894041735 67 2/13/2024
0.4.0-preview.7889205161 58 2/13/2024
0.4.0-preview.7887825195 63 2/13/2024
0.4.0-preview.7797649507 75 2/6/2024
0.4.0-preview.7797573922 65 2/6/2024
0.4.0-preview.7738700089 70 2/1/2024
0.4.0-preview.7733951421 65 1/31/2024
0.4.0-preview.7647762968 72 1/24/2024
0.4.0-preview.7637863202 58 1/24/2024
0.4.0-preview.7633843794 57 1/24/2024
0.4.0-preview.7633029380 58 1/23/2024
0.4.0-preview.7604871059 66 1/22/2024
0.4.0-preview.7590591848 66 1/20/2024
0.4.0-preview.7583858528 54 1/19/2024
0.4.0-preview.7582739690 58 1/19/2024
0.4.0-preview.7582261330 58 1/19/2024
0.3.0 530 11/15/2023
0.3.0-preview.7581632115 61 1/19/2024
0.3.0-preview.7534719969 61 1/15/2024
0.3.0-preview.7531251966 56 1/15/2024
0.3.0-preview.7531091190 66 1/15/2024
0.3.0-preview.6878318930 62 11/15/2023
0.3.0-preview.6863550581 68 11/14/2023
0.3.0-preview.6862085801 72 11/14/2023
0.3.0-preview.6861409332 70 11/14/2023
0.3.0-preview.6856367379 71 11/13/2023
0.3.0-preview.6818261260 75 11/9/2023
0.3.0-preview.6811974782 73 11/9/2023
0.3.0-preview.6810157968 69 11/9/2023
0.3.0-preview.6796543211 67 11/8/2023
0.3.0-preview.6773636635 71 11/6/2023
0.2.1 404 10/19/2023
0.2.1-preview.6575896737 70 10/19/2023
0.2.1-preview.6573766486 70 10/19/2023
0.2.1-preview.6564229721 78 10/18/2023
0.2.0 395 10/16/2023
0.2.0-preview.6534500637 73 10/16/2023
0.1.0 442 9/19/2023