Piral.Blazor.Orchestrator 0.5.0-preview.8768228498

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.5.0-preview.8768228498
                    
NuGet\Install-Package Piral.Blazor.Orchestrator -Version 0.5.0-preview.8768228498
                    
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.5.0-preview.8768228498" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Piral.Blazor.Orchestrator" Version="0.5.0-preview.8768228498" />
                    
Directory.Packages.props
<PackageReference Include="Piral.Blazor.Orchestrator" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Piral.Blazor.Orchestrator --version 0.5.0-preview.8768228498
                    
#r "nuget: Piral.Blazor.Orchestrator, 0.5.0-preview.8768228498"
                    
#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.
#:package Piral.Blazor.Orchestrator@0.5.0-preview.8768228498
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Piral.Blazor.Orchestrator&version=0.5.0-preview.8768228498&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Piral.Blazor.Orchestrator&version=0.5.0-preview.8768228498&prerelease
                    
Install as a Cake Tool

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.

// Important - an `HttpClient` needs to be present for the MfDiscoveryLoaderService - for
// other services it might not be needed; so you can regard this as optional
builder.Services.AddHttpClient();
// 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.AddRazorComponents()
    .AddInteractiveServerComponents();

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.UseAntiforgery();
app.UseMicrofrontends();

app.MapMicrofrontends<App>();

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 script, i.e., transform your App.razor to have no <script> tag such as:

<!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="app.css" />
    <HeadOutlet />
</head>

<body>
    <Routes @rendermode="InteractiveServer" />
</body>
</html>

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

Extended Configuration

By default, the micro frontend loader takes an empty feed of micro frontends. This way, nothing will be loaded and the application will remain empty with respect to the loaded micro frontends. To change this you will need to adjust the configuration, e.g., by modifying the appsettings.json file:

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*",
  "Microfrontends": {
    "CacheDir": ".cache",
    "DiscoveryInfoUrl": "https://feed.piral.cloud/api/v1/microfrontends/myfeed",
    "DiscoveryUpdateUrl": "wss://feed.piral.cloud/api/v1/pilet/myfeed",
    "NugetFeeds": {
      "Source": {
        "Url": "https://feed.piral.cloud/api/v1/nuget/myfeed/index.json"
      },
      "Public": {
        "Url": "https://api.nuget.org/v3/index.json"
      }
    }
  }
}

The given configuration is an example. The Microfrontends section is used to include the respective configuration. If this configuration is not present then default values (which match the shown values exactly) are applied. If you, e.g., want to have your cache stored in a different (relative or absolute) directory you'd need to have at least a property CacheDir in the config.

The NugetFeeds need to have all the feeds you want to use for resolving the dependencies of your micro frontends. Keep in mind that the actual nupkg file containing the micro frontends also needs to be hosted somewhere. This feed, which is usually referenced from the feed service, therefore also needs to be part of this configuration.

An example with more NuGet feeds:

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*",
  "Microfrontends": {
    "CacheDir": ".cache",
    "DiscoveryInfoUrl": "https://feed.piral.cloud/api/v1/microfrontends/myfeed",
    "DiscoveryUpdateUrl": "wss://feed.piral.cloud/api/v1/pilet/myfeed",
    "NugetFeeds": {
      "Source": {
        "Url": "https://feed.piral.cloud/api/v1/nuget/myfeed/index.json"
      },
      "Public": {
        "Url": "https://api.nuget.org/v3/index.json"
      },
      "GitHub": {
        "Url": "https://nuget.pkg.github.com/MyUserName/index.json",
        "User": "",
        "Token": ""
      },
      "Telerik": {
        "Url": "https://nuget.telerik.com/v3/index.json",
        "User": "",
        "Token": ""
      }
    }
  }
}

As you can see the User and Token fields, which are usually required for authenticating against a private feed, are left empty. This is not a mistake, but actually a best practice. You can use the .NET secret manager to then fill these parts. More details can be found in the Microsoft documentation.

Initial Options

The behavior of the library can be configured when the DI services are configured, e.g.:

builder.Services.AddMicrofrontends<MfDiscoveryLoaderService>(new()
{
    IsolatedAssemblies = ["BlazorOcticons.dll"],
});

This will instruct the Piral orchestrator to keep loading the locally available (yet centrally provided) BlazorOctions.dll.

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.  net9.0 was computed.  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 was computed.  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. 
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
1.0.0 196 5/3/2025
1.0.0-preview.15032838973 214 5/14/2025
1.0.0-preview.14879604889 134 5/7/2025
1.0.0-preview.14814030658 71 5/3/2025
1.0.0-preview.14813943958 62 5/3/2025
0.5.1 277 4/13/2025
0.5.1-preview.14430174911 181 4/13/2025
0.5.1-preview.14402538938 118 4/11/2025
0.5.0 200 3/27/2025
0.5.0-preview.9323268279 153 5/31/2024
0.5.0-preview.9024802187 84 5/9/2024
0.5.0-preview.8970923590 113 5/6/2024
0.5.0-preview.8961943566 84 5/5/2024
0.5.0-preview.8937540881 68 5/3/2024
0.5.0-preview.8924267614 57 5/2/2024
0.5.0-preview.8924038944 58 5/2/2024
0.5.0-preview.8919570786 83 5/2/2024
0.5.0-preview.8916013860 96 5/1/2024
0.5.0-preview.8870989656 81 4/28/2024
0.5.0-preview.8846899499 102 4/26/2024
0.5.0-preview.8831737080 86 4/25/2024
0.5.0-preview.8817031997 95 4/24/2024
0.5.0-preview.8785877670 86 4/22/2024
0.5.0-preview.8768228498 106 4/20/2024
0.5.0-preview.8766464948 87 4/20/2024
0.5.0-preview.8552466834 111 4/4/2024
0.5.0-preview.8538723932 355 4/3/2024
0.5.0-preview.8538694667 80 4/3/2024
0.5.0-preview.8489808898 104 3/30/2024
0.5.0-preview.8378016864 76 3/21/2024
0.5.0-preview.14111244135 126 3/27/2025
0.5.0-preview.14111107440 118 3/27/2025
0.5.0-preview.13980934142 159 3/20/2025
0.5.0-preview.13975780120 164 3/20/2025
0.5.0-preview.13859826695 109 3/14/2025
0.5.0-preview.12163386433 94 12/4/2024
0.5.0-preview.12163052794 100 12/4/2024
0.5.0-preview.10938254736 114 9/19/2024
0.5.0-preview.10937840879 95 9/19/2024
0.5.0-preview.10937538276 97 9/19/2024
0.5.0-preview.10903389206 110 9/17/2024
0.5.0-preview.10301764169 91 8/8/2024
0.4.1 658 2/16/2024
0.4.1-preview.7933391150 110 2/16/2024
0.4.1-preview.7924227833 108 2/16/2024
0.4.1-preview.7923896542 105 2/16/2024
0.4.1-preview.7922609748 82 2/15/2024
0.4.1-preview.7922124111 87 2/15/2024
0.4.1-preview.7921989076 100 2/15/2024
0.4.1-preview.7917520828 87 2/15/2024
0.4.0 294 2/13/2024
0.4.0-preview.7894041735 102 2/13/2024
0.4.0-preview.7889205161 83 2/13/2024
0.4.0-preview.7887825195 102 2/13/2024
0.4.0-preview.7797649507 107 2/6/2024
0.4.0-preview.7797573922 104 2/6/2024
0.4.0-preview.7738700089 88 2/1/2024
0.4.0-preview.7733951421 107 1/31/2024
0.4.0-preview.7647762968 97 1/24/2024
0.4.0-preview.7637863202 79 1/24/2024
0.4.0-preview.7633843794 77 1/24/2024
0.4.0-preview.7633029380 83 1/23/2024
0.4.0-preview.7604871059 105 1/22/2024
0.4.0-preview.7590591848 102 1/20/2024
0.4.0-preview.7583858528 93 1/19/2024
0.4.0-preview.7582739690 103 1/19/2024
0.4.0-preview.7582261330 79 1/19/2024
0.3.0 562 11/15/2023
0.3.0-preview.7581632115 100 1/19/2024
0.3.0-preview.7534719969 94 1/15/2024
0.3.0-preview.7531251966 78 1/15/2024
0.3.0-preview.7531091190 100 1/15/2024
0.3.0-preview.6878318930 85 11/15/2023
0.3.0-preview.6863550581 100 11/14/2023
0.3.0-preview.6862085801 98 11/14/2023
0.3.0-preview.6861409332 95 11/14/2023
0.3.0-preview.6856367379 94 11/13/2023
0.3.0-preview.6818261260 115 11/9/2023
0.3.0-preview.6811974782 97 11/9/2023
0.3.0-preview.6810157968 113 11/9/2023
0.3.0-preview.6796543211 90 11/8/2023
0.3.0-preview.6773636635 103 11/6/2023
0.2.1 451 10/19/2023
0.2.1-preview.6575896737 115 10/19/2023
0.2.1-preview.6573766486 113 10/19/2023
0.2.1-preview.6564229721 119 10/18/2023
0.2.0 445 10/16/2023
0.2.0-preview.6534500637 110 10/16/2023
0.1.0 516 9/19/2023