Skip to content

AddViteIntegration

NuGet: TechGems.ViteDotNet Extension methods

Registers the Vite.NET integration on the dependency-injection container. Call it once in Program.cs. Three overloads let you source the app directory name(s) from configuration or supply them directly.

using ViteDotNet;
public static void AddViteIntegration(
this IServiceCollection services,
IConfiguration configuration)

Reads the app directory name(s) from the ViteDotNet configuration section — either a single string or an array of strings.

Program.cs
builder.Services.AddViteIntegration(builder.Configuration);
ParameterTypeDescription
configurationIConfigurationThe app configuration; the ViteDotNet section is read from it.
public static void AddViteIntegration(
this IServiceCollection services,
string appDirectory)

Registers a single app directory directly, bypassing configuration.

Program.cs
builder.Services.AddViteIntegration("ReactApp");
ParameterTypeDescription
appDirectorystringThe directory name of the integrated Vite app (e.g. "ReactApp").
public static void AddViteIntegration(
this IServiceCollection services,
IEnumerable<string> appDirectories)

Registers one or more app directories directly.

Program.cs
builder.Services.AddViteIntegration(new[] { "ReactApp", "SvelteApp" });
ParameterTypeDescription
appDirectoriesIEnumerable<string>The directory names of the integrated Vite apps.

The IConfiguration overload reads this section, accepting either form:

{ "ViteDotNet": "ReactApp" }
{ "ViteDotNet": [ "ReactApp", "SvelteApp" ] }

If the section is missing or empty, no directories are registered and the tag helpers will throw when used. See Backend Configuration.