-
Create a new Blazor project or use an existing one (.NET 6 or later).
- Command line: Run
dotnet new blazor
- Visual Studio: Select File->New->Project... then choose Blazor Web App
Note: Smart Components work equally in any render mode (e.g., Static SSR, Server, or WebAssembly) but you do need to have an ASP.NET Core server, so you cannot use a Blazor WebAssembly Standalone App hosted on a static file server. This is purely because you need a server to hold your API keys securely.
- Command line: Run
-
Install packages
-
In your server project, install the NuGet package
SmartComponents.AspNetCore
.- Command line:
dotnet add package --prerelease SmartComponents.AspNetCore
- Visual Studio: Right-click your project name, choose Manage NuGet packages..., and then search for and install
SmartComponents.AspNetCore
.- Note: Check the Include prerelease option if needed.
- Command line:
-
If you also have a WebAssembly project, install the NuGet package
SmartComponents.AspNetCore.Components
into it. This is not required if you only have a server project.
-
-
Register SmartComponents in your application
In your server's
Program.cs
, under the comment// Add services to the container
, add:builder.Services.AddSmartComponents();
-
Configure the OpenAI backend (if needed)
If you will be using either
SmartPaste
orSmartTextArea
, you need to provide access to a language model backend. See: Configure the OpenAI backend.If you will only use
SmartComboBox
, you don't need any language model backend and can skip this step. -
Add components to your pages
You can now add the following inside your Blazor pages/components: