NgSharp v3 — a template engine for .NET
Author — NuGet · MIT
Angular-style interpreted templates, format-agnostic: parses any text file with deep HTML awareness. Zero dependencies, Native AOT compatible.
first render in microseconds
The problem
Rendering HTML server-side in .NET usually means code generation: Razor compiles its views through Roslyn. That compilation weighs on cold start and rules out Native AOT.
The approach
NgSharp interprets instead of compiling. It parses the template into an AST on first use, caches the tree, then renders by walking it: no Roslyn, no IL emit, so cold start is instant and the reflection-free path stays Native AOT compatible. One dependency: System.Text.Json.
In practice
Highlights
- Angular-style syntax: interpolation, pipes, @if/@for, safe navigation
- Interpreted: AST cached, no generated code
- Native AOT and trimming compatible, reflection-free
- Immutable, thread-safe AST: parsed once, rendered concurrently
- Purpose-built HTML parser, a single runtime dependency (System.Text.Json)
Stack
- C#
- .NET 9
- Native AOT