Piral.Blazor.Shared 0.4.0-preview.7889205161

This is a prerelease version of Piral.Blazor.Shared.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Piral.Blazor.Shared --version 0.4.0-preview.7889205161
                    
NuGet\Install-Package Piral.Blazor.Shared -Version 0.4.0-preview.7889205161
                    
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.Shared" Version="0.4.0-preview.7889205161" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Piral.Blazor.Shared" Version="0.4.0-preview.7889205161" />
                    
Directory.Packages.props
<PackageReference Include="Piral.Blazor.Shared" />
                    
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.Shared --version 0.4.0-preview.7889205161
                    
#r "nuget: Piral.Blazor.Shared, 0.4.0-preview.7889205161"
                    
#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.Shared@0.4.0-preview.7889205161
                    
#: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.Shared&version=0.4.0-preview.7889205161&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Piral.Blazor.Shared&version=0.4.0-preview.7889205161&prerelease
                    
Install as a Cake Tool

Piral Logo

Piral.Blazor.Shared · GitHub License | GitHub Tag GitHub Issues Gitter Chat

The shared module with common type definitions for micro frontends using Blazor.

Installation & Setup

This is a shared library that will be automatically installed and used with Piral.Blazor.Orchestrator or in a micro frontend when you leverage the Piral.Blazor.Sdk SDK like this:

<Project Sdk="Piral.Blazor.Sdk/0.4.0">

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <Version>1.0.0</Version>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <AppShell>My.Emulator/0.1.0</AppShell>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="BlazorGoogleMaps" Version="3.1.2" />
    <PackageReference Include="BlazorOcticons" Version="1.0.4" />
  </ItemGroup>

</Project>

The example shows a micro frontend using an app shell deployed as My.Emulator in version 1.0.0. The micro frontend brings its own dependencies, namely BlazorGoogleMaps and BlazorOcticons.

Creating Micro Frontends

Prerequisites

From scratch you can create a new Razor Component Library (RCL) project. By changing the csproj file's SDK to Piral.Blazor.Sdk you will be able to debug / develop this very conveniently.

The RCL has to be for .NET 8.

Module Definition / Registration and Usage of Components

In order to be a valid micro frontend there has to be one public class that inherits from IMfModule:

public class Module : IMfModule
{
    public Module(IConfiguration configuration)
    {
        // Inject here what you want, e.g., the global `IConfiguration`.
    }

    public void Configure(IServiceCollection services)
    {
        // Configure your services in this function
    }

    public Task Setup(IMfAppService app)
    {
        // Register components and more
        return Task.CompletedTask;
    }

    public Task Teardown(IMfAppService app)
    {
        // Unregister things that need to be cleaned up
        return Task.CompletedTask;
    }
}

In the Setup function you can wire up your components to names that can be used on the outside. For instance, to wire up a MapComponent Razor component to an outside name of "mfa-map" you can do:

app.MapComponent<MapComponent>("mfa-map");

If you need to set up more things - such as scripts or stylesheets used by your dependencies you'd do:

app.AppendScript($"https://mycdn.com/some-global-script.js");
app.AppendScript("_content/BlazorGoogleMaps/js/objectManager.js");

The paths will be set up / configured correctly by the app shell.

Dependencies

Just install your dependencies as you like; if they are correctly in the csproj they will be correctly in the NuGet package.

Using Components from Micro Frontends

To use a component (such as "mfa-components" - this name is defined by the micro frontend calling the MapComponent method of the IMfAppService instance passed to their module definition - see below) without any parameters:

<MfComponent Name="mfa-component" />

You can also specify parameters if necessary / wanted:

<MfComponent Name="mfa-component" Parameters="@parameters" />

where

private Dictionary<string, object> parameters = new Dictionary<string, object>
{
  { "Foo", 5 }
};

The MfComponent component is available in the Piral.Blazor.Shared NuGet package. It can be used in the server / app shell or in any micro frontend.

Alternatively, you can also specify parameters directly, e.g., for the previous example you could also write:

<MfComponent Name="mfa-component" Foo="5" />
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 (1)

Showing the top 1 NuGet packages that depend on Piral.Blazor.Shared:

Package Downloads
Piral.Blazor.Orchestrator

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

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 145 5/3/2025
1.0.0-preview.15032838973 199 5/14/2025
1.0.0-preview.14879604889 124 5/7/2025
1.0.0-preview.14814030658 45 5/3/2025
1.0.0-preview.14813943958 48 5/3/2025
0.5.1 225 4/13/2025
0.5.1-preview.14430174911 155 4/13/2025
0.5.1-preview.14402538938 107 4/11/2025
0.5.0 170 3/27/2025
0.5.0-preview.9323268279 242 5/31/2024
0.5.0-preview.9024802187 81 5/9/2024
0.5.0-preview.8970923590 90 5/6/2024
0.5.0-preview.8961943566 75 5/5/2024
0.5.0-preview.8937540881 49 5/3/2024
0.5.0-preview.8924267614 44 5/2/2024
0.5.0-preview.8924038944 49 5/2/2024
0.5.0-preview.8919570786 54 5/2/2024
0.5.0-preview.8916013860 62 5/1/2024
0.5.0-preview.8870989656 69 4/28/2024
0.5.0-preview.8846899499 93 4/26/2024
0.5.0-preview.8831737080 80 4/25/2024
0.5.0-preview.8817031997 73 4/24/2024
0.5.0-preview.8785877670 91 4/22/2024
0.5.0-preview.8768228498 81 4/20/2024
0.5.0-preview.8766464948 72 4/20/2024
0.5.0-preview.8552466834 92 4/4/2024
0.5.0-preview.8538723932 324 4/3/2024
0.5.0-preview.8538694667 85 4/3/2024
0.5.0-preview.8489808898 80 3/30/2024
0.5.0-preview.8378016864 89 3/21/2024
0.5.0-preview.14111244135 108 3/27/2025
0.5.0-preview.14111107440 111 3/27/2025
0.5.0-preview.13980934142 139 3/20/2025
0.5.0-preview.13975780120 127 3/20/2025
0.5.0-preview.13859826695 83 3/14/2025
0.5.0-preview.12163386433 65 12/4/2024
0.5.0-preview.12163052794 71 12/4/2024
0.5.0-preview.10938254736 89 9/19/2024
0.5.0-preview.10937840879 71 9/19/2024
0.5.0-preview.10937538276 82 9/19/2024
0.5.0-preview.10903389206 96 9/17/2024
0.5.0-preview.10301764169 87 8/8/2024
0.4.1 651 2/16/2024
0.4.1-preview.7933391150 91 2/16/2024
0.4.1-preview.7924227833 76 2/16/2024
0.4.1-preview.7923896542 83 2/16/2024
0.4.1-preview.7922609748 82 2/15/2024
0.4.1-preview.7922124111 75 2/15/2024
0.4.1-preview.7921989076 83 2/15/2024
0.4.1-preview.7917520828 88 2/15/2024
0.4.0 194 2/13/2024
0.4.0-preview.7894041735 85 2/13/2024
0.4.0-preview.7889205161 79 2/13/2024
0.4.0-preview.7887825195 83 2/13/2024
0.4.0-preview.7797649507 94 2/6/2024
0.4.0-preview.7797573922 79 2/6/2024
0.4.0-preview.7738700089 89 2/1/2024
0.4.0-preview.7733951421 80 1/31/2024
0.4.0-preview.7647762968 82 1/24/2024
0.4.0-preview.7637863202 74 1/24/2024
0.4.0-preview.7633843794 74 1/24/2024
0.4.0-preview.7633029380 82 1/23/2024
0.4.0-preview.7604871059 84 1/22/2024
0.4.0-preview.7590591848 82 1/20/2024
0.4.0-preview.7583858528 78 1/19/2024
0.4.0-preview.7582739690 77 1/19/2024
0.4.0-preview.7582261330 74 1/19/2024
0.3.0 420 11/15/2023
0.3.0-preview.7581632115 78 1/19/2024
0.3.0-preview.7534719969 73 1/15/2024
0.3.0-preview.7531251966 81 1/15/2024
0.3.0-preview.7531091190 79 1/15/2024
0.3.0-preview.6878318930 78 11/15/2023
0.3.0-preview.6863550581 84 11/14/2023
0.3.0-preview.6862085801 88 11/14/2023
0.3.0-preview.6861409332 88 11/14/2023
0.3.0-preview.6856367379 85 11/13/2023
0.3.0-preview.6818261260 95 11/9/2023
0.3.0-preview.6811974782 90 11/9/2023
0.3.0-preview.6810157968 84 11/9/2023
0.3.0-preview.6796543211 88 11/8/2023
0.3.0-preview.6773636635 98 11/6/2023
0.2.1 299 10/19/2023
0.2.1-preview.6575896737 93 10/19/2023
0.2.1-preview.6573766486 90 10/19/2023
0.2.1-preview.6564229721 100 10/18/2023
0.2.0 295 10/16/2023
0.2.0-preview.6534500637 91 10/16/2023
0.1.0 302 9/19/2023