Backend Configuration
The back end’s configuration has been reduced to a single thing: the directory name(s) of the
integrated Vite app(s). Every other value the back end needs is read from the manifests the plugin
emits into wwwroot.
The ViteDotNet section
Section titled “The ViteDotNet section”Add the app folder name under the ViteDotNet key. It accepts either a single string or an array.
{ "ViteDotNet": "ReactApp"}{ "ViteDotNet": [ "ReactApp", "SvelteApp" ]}The value(s) must match the SPA folder names — the same names the plugin derives from each app’s
working directory, and the folders the manifests are written under in wwwroot.
Registering the integration
Section titled “Registering the integration”Register the integration on the service collection in Program.cs. There are three overloads.
From configuration
Section titled “From configuration”Reads the app directory name(s) from the ViteDotNet configuration section:
builder.Services.AddViteIntegration(builder.Configuration);A single directory in code
Section titled “A single directory in code”Bypasses configuration and registers one app directly:
builder.Services.AddViteIntegration("ReactApp");Multiple directories in code
Section titled “Multiple directories in code”builder.Services.AddViteIntegration(new[] { "ReactApp", "SvelteApp" });Registering the tag helpers
Section titled “Registering the tag helpers”The tag helpers live in the ViteDotNet assembly. Register them in _ViewImports.cshtml (in the
Pages folder for Razor Pages, or Views for MVC):
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers@addTagHelper *, ViteDotNetThis makes <dev-vite-scripts> and <prod-vite-scripts> available in your pages.
What you no longer configure
Section titled “What you no longer configure”Compared with older versions, these values are no longer in your backend config — they come from the manifests instead:
- The entrypoint (
src/main.tsx) - The container element id (
root) - The dev-server port
- Whether the app is React
They live in vite.config.ts (the plugin’s arguments) and are emitted into the manifests at dev
and build time. See How It Works and, if you’re upgrading, the
Migrating from v0 guide.