Skip to content
Introducing AI Conversations: Natural Language Interaction for Your Apps! Learn More

MAUI Hosting

MAUI apps often end up with a massive MauiProgram.cs where every plugin, service, and lifecycle hook is crammed together. Shiny MAUI Hosting lets you break that apart into modular IMauiModule classes — each responsible for its own service registration and post-build initialization. It also provides a static Host.Services accessor, an IAppSupport service for orientation/culture/time-zone change detection and device info, and an IAppStore service for cross-platform store version lookups and deep links.

GitHubGitHub stars for shinyorg/extensions
DownloadsNuGet downloads for Shiny.Extensions.MauiHosting
Frameworks
.NET MAUI
  • Modular IMauiModule interface — combines service registration and post-build initialization in one class
  • Static Host.Services for accessing the service provider from anywhere
  • IAppSupport — device info, orientation control, and live change notifications for orientation, culture, and time zone
  • IAppStore — cross-platform store version lookups, deep links, and review-page launches for Apple App Store, Google Play, and Microsoft Store
  • Opt-in registration: each capability ships as its own extension method (AddAppSupport, AddAppStore) so apps only pay for what they use
  1. Install the NuGet package:

    Terminal window
    dotnet add package Shiny.Extensions.MauiHosting
  2. Create a module for each concern:

    using Shiny;
    public class MyModule : IMauiModule
    {
    public void Add(MauiAppBuilder builder)
    {
    builder.Services.AddSingleton<IMyService, MyService>();
    }
    public void Use(IPlatformApplication app)
    {
    // Post-build initialization (do NOT block here)
    }
    }
  3. Wire everything up in MauiProgram.cs:

    using Shiny;
    var builder = MauiApp.CreateBuilder();
    builder
    .UseMauiApp<App>()
    .AddInfrastructureModules(new MyModule()) // your IMauiModule list
    .AddAppSupport() // IAppSupport
    .AddAppStore(opts => // IAppStore (omit if not needed)
    {
    opts.AppleAppId = "1234567890";
    opts.WindowsProductId = "9NBLGGH4NNS1";
    });
    return builder.Build();

Each module implements IMauiModule with two methods:

  • Add(MauiAppBuilder builder) — register services, configure the builder. This runs before the app is built.
  • Use(IPlatformApplication app) — post-build initialization. The service provider is available via Host.Services. Do NOT block here — this runs on the main thread during app startup.
public class AnalyticsModule : IMauiModule
{
public void Add(MauiAppBuilder builder)
{
builder.Services.AddSingleton<IAnalytics, AppCenterAnalytics>();
}
public void Use(IPlatformApplication app)
{
var analytics = Host.Services.GetRequiredService<IAnalytics>();
analytics.TrackEvent("AppStarted");
}
}

After the app is built and initialized, Host.Services provides access to the service provider from anywhere:

// Resolve a service from anywhere in your app
var service = Host.Services.GetRequiredService<IMyService>();

IAppSupport provides device info, browser/map helpers, programmatic orientation control, and live change notifications for orientation, culture, and time zone. See App Support for the full member list and platform notes.

IAppStore looks up the latest published version from the relevant platform store and deep-links into the store or review page. See App Store for configuration options and per-platform behavior.

claude plugin marketplace add shinyorg/skills
claude plugin install shiny-extensions@shiny
copilot plugin marketplace add https://github.com/shinyorg/skills
copilot plugin install shiny-extensions@shiny
View shiny-extensions Plugin