Svelte 5 islands for ASP.NET Razor Pages and MVC — SvelteKit-style typed data props, forms, and remote functions, powered by your C# models.
- Svelte 5 / runes — components receive props via
$props(), mounted withmount/hydrate; experimental await expressions supported (sveltenet({ experimentalAsync: true })). - SSR is opt-in and interchangeable — stay client-only, run in-process with Jint, use an installed Node.js/Bun CLI, or plug in your own
ISvelteSsrEngine. - Typed everything, generated for you —
[SvelteProp]page models,[SvelteComponent]MVC view models, and[SvelteRemote]services all emit TypeScript; remote dispatch is compiled by a Roslyn source generator. - SvelteKit-style remote functions —
[Query]/[Command]/[Form]methods becomequery/command/formclients with caching,refresh(),.updates(), fields/issues state, and no-JS fallbacks. - One-plugin Vite setup —
plugins: [sveltenet()]builds client + SSR bundles in a singlevite build; full HMR in development.
// Program.cs
using SvelteNet.AspNetCore;
builder.Services.AddRazorPages();
builder.Services.AddSvelteNet(); // client-only
// Or: builder.Services.AddSvelteNet().AddJintSSR();
var app = builder.Build();
app.UseStaticFiles();
app.UseSvelteNet(); // maps /_sveltenet/remote
app.MapRazorPages();public class IndexModel : SveltePage
{
[SvelteProp] public List<Todo> Todos { get; set; } = [];
}@model IndexModel
@section Head { @Model.SvelteHead() }
@Model.Svelte()Run dotnet build once. The bundled analyzer and build target generate ambient declarations under .svelte-net/types and scaffold missing user-owned .svelte/Vite files. Then run npm install + npm run dev alongside dotnet watch run.
- Getting started — setup, scaffolding, project layout
- Dev mode & hot reload — the two-terminal workflow, HMR, caveats
- Forms & enhance — page forms,
data.problem, antiforgery, progressive enhancement - MVC views —
[SvelteComponent]typed rendering,@Html.Svelte - Remote functions —
[Query]/[Command]/[Form], the typed client, source-generated dispatch - SSR renderers — opt-in Jint, Node.js, Bun, and custom renderers
- Security — authorization, CSRF, and what the SSR bridge enforces
- Options — shared and renderer-specific configuration
src/ SvelteNet.Core — renderer, serialization contract, TypeScript generation (NuGet)
SvelteNet.AspNetCore — ASP.NET integration, Node/Bun SSR, remote endpoints (NuGet)
SvelteNet.Jint — in-process Jint server rendering (NuGet, optional)
SvelteNet.Generators — Roslyn source generator for remote dispatch
SvelteNet.Build — MSBuild target: dotnet build generates the TS types
SvelteNet.FluentValidation — FluentValidation adapter for the validation pipeline
packages/ sveltenet — Vite plugin + client/remote runtimes (npm)
samples/ TodoApp — Razor Pages: typed props, forms, enhance()
RemoteFunctions — vertical-slice query/command/form functions and async SSR
MvcHello — MVC controllers with [SvelteComponent]
tests/ SvelteNet.Core.Tests, SvelteNet.AspNetCore.Tests
docs/ the documentation above (also a VitePress site: bun run docs:dev)
The repo uses bun (bun.lock is committed), but every script calls tools directly, so npm/pnpm work too.
dotnet test SvelteNet.slnx # .NET unit + integration tests
bun install # workspace install (packages/ + samples/ + docs/)
cd packages/sveltenet && bun run test # JS tests
cd samples/TodoApp && dotnet run # any sample: see samples/README.md
bun run docs:dev # documentation sitePrototype — not yet published to NuGet or npm. See ROADMAP.md for what's next (publishing and Blazor/Blazor-SSR hosting) and what has shipped.