Getting Started with .NET MAUI Blazor Hybrid and Blazor Web App

16 Jul 20254 minutes to read

This section explains how to create and run the first .NET Multi-platform Blazor App UI (.NET MAUI with Blazor Web App) app with Syncfusion® Blazor components.

What is .NET MAUI Blazor Hybrid and Web App?

.NET MAUI Blazor Web App is a hybrid application that leverages a Razor Class Library (RCL) to define reusable Blazor components. These components are shared between a Blazor WebAssembly or Server app and a .NET MAUI Blazor app. This setup allows developers to create a unified web-based UI and reuse it across mobile, desktop, and browser platforms.

By sharing UI components between native and web apps, this approach ensures consistent user experiences, promotes maximum code reuse, and simplifies maintenance for applications that target multiple environments.

Visual Studio provides .NET MAUI Blazor Hybrid and Web App template to create .NET MAUI Blazor Hybrid app with a Blazor Web App.

Prerequisites

  • .NET SDK 9.0 and later.

  • The latest preview of Visual Studio 2022 17.3 or above, with required workloads:

Create a new .NET MAUI Blazor Hybrid and Blazor Web App in Visual Studio

You can create a .NET MAUI Blazor Hybrid and Blazor Web App using Visual Studio via Microsoft Templates

.NET MAUI Blazor Hybrid and Blazor Web App

Install Syncfusion® Blazor Calendars and Themes NuGet in the App

Here’s an example of how to add Blazor Calendar component in the app’s shared folder, open the NuGet package manager in Visual Studio (Tools → NuGet Package Manager → Manage NuGet Packages for Solution), search and install Syncfusion.Blazor.Calendars and Syncfusion.Blazor.Themes. Alternatively, you can utilize the following package manager command to achieve the same.

Install-Package Syncfusion.Blazor.Calendars -Version 30.2.4
Install-Package Syncfusion.Blazor.Themes -Version 30.2.4

NOTE

Syncfusion® Blazor components are available in nuget.org. Refer to NuGet packages topic for available NuGet packages list with component details.

Register Syncfusion® Blazor Service

Open ~/_Imports.razor file in both .Maui and .Web App and import the Syncfusion.Blazor and Syncfusion.Blazor.Calendars namespace.

@using Syncfusion.Blazor
@using Syncfusion.Blazor.Calendars

Now, register the Syncfusion® Blazor service in both the MauiProgram.cs file of your MAUI Blazor App and ~/Program.cs file of your Blazor Web App.

using Syncfusion.Blazor;
    ....
    builder.Services.AddMauiBlazorWebView();
    builder.Services.AddSyncfusionBlazor();
    ....
using Syncfusion.Blazor;
    
    var builder = WebApplication.CreateBuilder(args);

    // Add services to the container.
    builder.Services.AddRazorComponents()
        .AddInteractiveServerComponents();
    builder.Services.AddSyncfusionBlazor();
    ....

Add stylesheet and script resources

The theme stylesheet and script can be accessed from NuGet through Static Web Assets. Reference the stylesheet and script in the <head> of the ~wwwroot/index.html file of your MAUI Blazor App and ~/Components/App.razor file of your Blazor Web App.

<head>
    ....
    <link href="_content/Syncfusion.Blazor.Themes/bootstrap5.css" rel="stylesheet" />
</head>

<body>
    ....
    <script src="_content/Syncfusion.Blazor.Core/scripts/syncfusion-blazor.min.js" type="text/javascript"></script>
</body>

NOTE

Check out the Blazor Themes topic to discover various methods (Static Web Assets, CDN, and CRG) for referencing themes in your Blazor application. Also, check out the Adding Script Reference topic to learn different approaches for adding script references in your Blazor application.

Add Syncfusion® Blazor component

Now add Syncfusion® Blazor component in any razor file. Here, the Calendar component is added in ~/Pages/Home.razor page under the ~/Pages folder of your .Shared App .

@using Syncfusion.Blazor.Calendars

<SfCalendar TValue="DateTime"></SfCalendar>

In the Visual Studio toolbar, select the Windows Machine button to build and run the .Maui app.
Before running the sample, make sure the mode is Windows Machine. Also to build and run the .Web app, select the IIS Express button.

Build and run MAUI Blazor App

NOTE

If you want to run the application in Android or iOS refer MAUI Getting Started for the setup.

MAUI Blazor App with Syncfusion Blazor Components

NOTE

Download demo from GitHub

See also

MAUI Blazor App

NOTE

View MAUI Blazor Diagram Builder Source Code in GitHub