Create a Blazor Web App
- 4 minutes to read
This topic contains detailed instructions on how to create Blazor Web App applications from both DevExpress and Microsoft templates in Visual Studio and the .NET CLI.
Important
Ensure your system meets these requirements.
The following options are available:
- Visual Studio: DevExpress Template Gallery (for Windows only)
- Visual Studio: DevExpress Template (for Windows only)
- .NET CLI: DevExpress Template (for all operating systems)
- Visual Studio: Microsoft Template (for Windows only)
- .NET CLI: Microsoft Template (for all operating systems)
Visual Studio: DevExpress Template Gallery
Follow the steps below to run the DevExpress Template Gallery in Visual Studio:
Open Visual Studio and click Create a new project on the start page.
In the Create a New Project dialog, select DevExpress v24.1 Blazor App Template Gallery and click Next.
Specify the Project Name and Location, and click Create.
In the invoked Template Gallery, specify Project Name, Target Framework, Render Mode, and Authentication options, and click Run Wizard.
The Project Wizard appears.
The wizard includes the following tabs:
Themes. Choose a built-in DevExpress theme or a Bootstrap theme.
Settings. This tab contains a different set of options for Blazor Server and WebAssembly applications:
- Component Size Mode - Specifies the size mode for DevExpress Blazor components. The wizard adds the SizeMode global option in the Program.cs file. Individual component settings can override this option.
- Progressive Web Application (available for a WebAssembly project in .NET6 and .NET7) - Specifies whether to create a Progressive Web Application (PWA). PWA brings a native desktop app user experience to cross-platform web applications. Launch PWA from the start menu, run it in its own app window, and work with it offline. You can specify PWA-specific settings in the wwwroot/manifest.json file.
- Add Rich Text Editor Resources - Adds Rich Text Editor packages to the project, imports the DevExpress.Blazor.Office and DevExpress.Blazor.RichEdit namespaces, and registers CSS resources for the Rich Editor component.
Click Create Project in the wizard.
Visual Studio: DevExpress Template
- Open Visual Studio and click Create a new project on the start page.
Select the DevExpress Blazor App (Developer Express Inc.) template and click Next.
Specify Project Name and Location, and click Next.
- Specify Framework, Authentication Type, and Render Mode, and click Create.
.NET CLI: DevExpress Template
Based on the render mode and framework version, run one of the following commands to create a project:
DevExpress Blazor App for .NET 6 or .NET 7:
dotnet new dx.blazor -n MyBlazorServerApp -f net7.0 -int Server
DevExpress Blazor App for .NET 8 or .NET 9:
dotnet new dx.blazor -n MyBlazorInteractiveServerApp -f net8.0 -int Server
The newly created project references the DevExpress.Blazor NuGet package. NuGet automatically restores this package if you registered the DevExpress NuGet feed.
You can also pass the NuGet feed as a -nf
parameter when you create a project. The following command creates the project and adds the NuGet.config file with the DevExpress feed to the project folder.
dotnet new dx.blazor -n MyBlazorServerApp -nf https://nuget.devexpress.com/{your-feed-authorization-key}/api/v3/index.json
To see the list of available template options, execute the following command:
dotnet new dx.blazor -h
Visual Studio: Microsoft Template
Follow the steps below to use Microsoft Blazor project templates in Visual Studio:
Click Create a new project on Visual Studio’s start page, select a Blazor template based on your content and hosting model preferences, and click Next.
Specify project name and location. Click Next.
Specify additional options (framework version, render mode, etc.), and click Create.
.NET CLI: Microsoft Template
Based on the render mode and framework version, run one of the following commands to create a project:
Blazor App for .NET 6 or .NET 7:
dotnet new blazorserver -n MyBlazorServerProject
Blazor App for .NET 8 or .NET 9:
dotnet new blazor -n MyBlazorInteractiveServerApp
Next Step
If you created a project from a DevExpress template and successfully restored NuGet packages, click the following button:
Otherwise, proceed to the following step: