In Development the renderer emits a different script — instead of hashed production assets, it imports straight from the Vite dev server:
<script type="module">
import "http://localhost:5173/@vite/client"; <!-- HMR runtime + websocket -->
import { mountComponent } from "http://localhost:5173/@id/sveltenet/client";
import App from "http://localhost:5173/Svelte/Index.svelte";
mountComponent(App, { target: ..., hydrate: false, props: {...} });
</script>ASP.NET serves the page and the props; Vite serves the components with transform-on-demand and pushes hot updates over its websocket. The daily workflow is two terminals:
dotnet watch run # C# hot reload; each rebuild regenerates .svelte-net/types
npm run dev # Svelte HMR — component edits appear in ~1s, no page reloadCaveats to know about:
- SSR is skipped in dev — the island mounts client-side (
mount, nothydrate). An explicitly registered renderer is used only in a production run. - Component
$stateresets on hot update — vite-plugin-svelte re-instantiates the component. Server-provideddatais unaffected. - Changing a
[SvelteProp]flows into the generated TypeScript on the next build (dotnet watchrebuilds for you). - Vite allows localhost origins by default, so the cross-origin module imports need no CORS config.