dev-vite-scripts
Tag helper
Development
Renders a SPA in development by loading the Vite client and your entrypoint from the running
dev server, giving you hot module replacement inside a Razor page. Reads
manifest.dev.json.
<dev-vite-scripts app-name="ReactApp" />Attributes
Section titled “Attributes”| Attribute | Type | Required | Description |
|---|---|---|---|
app-name | string | Only when more than one app is configured | The SPA directory name to render. With a single configured app it may be omitted. |
What it renders
Section titled “What it renders”- For React apps (
isReact: true), a<script static-script type="module">block injecting the React refresh runtime preamble. - The container element:
<div id="{containerElementId}"></div>. - A loader script that fetches your entrypoint from
http://localhost:{port}/{entrypoint}, and once it responds, appends the Vite client (/@vite/client) and the entrypoint as module scripts. - A fallback: if the entrypoint can’t be fetched within the retry window, it replaces the container contents with a “Vite Dev Server Not Found” message.
Resolved values
Section titled “Resolved values”The helper resolves these from the dev manifest (falling back to defaults if the manifest is absent because the dev server hasn’t started):
| Property | Source | Default |
|---|---|---|
Port | manifest.dev.json → port | 5173 |
Entrypoint | manifest.dev.json → entrypoint | "" |
ContainerElementId | manifest.dev.json → containerElementId | "app" |
IsReact | manifest.dev.json → isReact | false |
Requirements
Section titled “Requirements”-
The integration must be registered — see AddViteIntegration.
-
The tag helpers must be registered in
_ViewImports.cshtml:@addTagHelper *, ViteDotNet -
The Vite dev server must be running so
manifest.dev.jsonexists and the entrypoint is reachable.
Related
Section titled “Related”- prod-vite-scripts — the production counterpart.
- Development Workflow — running the dev server alongside .NET.