SpatialFocus.Blazor.Micromark.Server.V8 0.1.1

dotnet add package SpatialFocus.Blazor.Micromark.Server.V8 --version 0.1.1
                    
NuGet\Install-Package SpatialFocus.Blazor.Micromark.Server.V8 -Version 0.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SpatialFocus.Blazor.Micromark.Server.V8" Version="0.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SpatialFocus.Blazor.Micromark.Server.V8" Version="0.1.1" />
                    
Directory.Packages.props
<PackageReference Include="SpatialFocus.Blazor.Micromark.Server.V8" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SpatialFocus.Blazor.Micromark.Server.V8 --version 0.1.1
                    
#r "nuget: SpatialFocus.Blazor.Micromark.Server.V8, 0.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SpatialFocus.Blazor.Micromark.Server.V8@0.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SpatialFocus.Blazor.Micromark.Server.V8&version=0.1.1
                    
Install as a Cake Addin
#tool nuget:?package=SpatialFocus.Blazor.Micromark.Server.V8&version=0.1.1
                    
Install as a Cake Tool

SpatialFocus.Blazor.Micromark

A Blazor component that renders markdown in the browser with micromark.

CI NuGet

It renders CommonMark and GitHub Flavored Markdown (tables, strikethrough, task lists, autolinks and footnotes), and escapes HTML in the markdown by default. micromark comes inside the package as one JavaScript file of about 20 KB compressed.

Installation

dotnet add package SpatialFocus.Blazor.Micromark

The package targets .NET 10 and .NET 11.

Usage

Register the renderer in Program.cs:

using SpatialFocus.Blazor.Micromark;

builder.Services.AddMicromark();

Show markdown with the component. Attributes such as class go to the div it renders:

@using SpatialFocus.Blazor.Micromark

<Markdown Value="@text" class="notes" />

Or inject IMarkdownRenderer and render in code:

string html = await renderer.RenderAsync("# Hello *world*");

Options

MarkdownOptions goes to the component's Options parameter or to RenderAsync.

Option Default Effect
Gfm on Renders GitHub Flavored Markdown on top of CommonMark.
AllowDangerousHtml off HTML in the markdown reaches the output as HTML. Off, it is escaped.
AllowDangerousProtocol off Links and images keep URLs of any protocol, such as javascript:. Off, such a URL is dropped.

AllowDangerousHtml and AllowDangerousProtocol pass the markdown's HTML and URLs on unsanitized. Switch them on for markdown from a trusted source alone.

<Markdown Value="@text" Options="@(new MarkdownOptions { Gfm = false })" />

Hosting models

A JavaScript initializer in the package loads micromark before Blazor starts. On WebAssembly the component then renders synchronously, and the HTML is there with its first render. Where the initializer did not run, the renderer loads micromark on first use and the component shows the HTML once it arrives.

Hosting model With this package With a server package Tested
Standalone WebAssembly HTML with the first render ✅
Blazor Web App, Interactive WebAssembly HTML with the first render the same ✅
Blazor Web App, Interactive Server HTML after the first render, rendered in the browser the same ✅
Blazor Web App, Interactive Auto As Interactive Server on the first visit, as Interactive WebAssembly after it the same ✅
Prerendering Empty in the prerendered page, filled once the component is interactive HTML in the prerendered page, kept when the component becomes interactive ✅
Static server rendering Stays empty HTML ✅
Blazor Hybrid HTML after the first render (✅)*

* untested

On Interactive Server the HTML comes back from the browser over SignalR, whose incoming messages are limited to 32 KB by default. Markdown that renders to more needs a higher limit:

builder.Services.AddRazorComponents()
    .AddInteractiveServerComponents()
    .AddHubOptions(options => options.MaximumReceiveMessageSize = 64 * 1024);

Rendering on the server

Two packages run the same micromark on the server. Static server rendering and prerendering then show the HTML, and it is the HTML the browser renders.

Package Engine For
SpatialFocus.Blazor.Micromark.Server.Jint Jint, a JavaScript interpreter in managed code Short texts, on every platform .NET runs on
SpatialFocus.Blazor.Micromark.Server.V8 V8 through ClearScript Long texts and many renderings, where its conditions are met
dotnet add package SpatialFocus.Blazor.Micromark.Server.Jint
// Server project, AddMicromarkV8() with the V8 package
builder.Services.AddMicromarkJint();

// Client project
builder.Services.AddMicromark();

The engine renders the passes without interactivity, the browser the interactive ones. An interactive component on the server starts with the HTML of its prerender pass, so nothing flickers, and asks the browser only once the markdown changes. That HTML travels in the page, compressed and up to 6 KB for all its components. A component beyond that is rendered again once it is interactive. interactive: true in either call renders the interactive passes on the server as well, without the trip to the browser.

Neither package caches the HTML. micromark takes quadratic time for some texts, which matters where users write the markdown, so a rendering ends with a TimeoutException after five seconds. Both calls take another limit: AddMicromarkJint(configure: options => options.Timeout = TimeSpan.FromSeconds(1)).

JintMarkdownRenderer, V8MarkdownRenderer and BrowserMarkdownRenderer are public, so an IMarkdownRenderer of your own can wrap them, to cache the HTML for instance. Registered after AddMicromarkJint() or AddMicromarkV8(), it replaces the package's.

Jint

Jint is managed code and needs nothing beside .NET. It interprets JavaScript, so a rendering takes significantly longer than in a browser, which shows mostly with long texts.

V8

V8 compiles micromark to machine code, and a long text renders in a fraction of the time Jint takes. It comes with conditions:

  • Platforms: the package brings V8 for Windows x64 and Linux x64. An app on another platform references ClearScript's package for it, such as Microsoft.ClearScript.V8.Native.linux-arm64 or Microsoft.ClearScript.V8.Native.osx-arm64, in the version of Microsoft.ClearScript.V8. On Linux V8 needs glibc: ClearScript has no package for Alpine.
  • Size: V8 is a native library of tens of megabytes per platform. A publish for one runtime identifier holds that platform's alone.
  • Trimming and Native AOT: ClearScript works with neither.
  • Threads: a rendering runs on a thread of the renderer's own. The renderer keeps up to MaximumConcurrentRenderings of them and one more that ends the renderings beyond the timeout. The caller waits a moment for its rendering, in which a text of usual length is rendered, so its HTML comes with the component's first render. The HTML of a longer text follows: a static page waits for it, an interactive component shows it once it is there.
  • Memory: V8 keeps a heap of its own beside .NET's. MaximumHeapSize, 128 MB by default, limits it for one rendering, which ends with an InsufficientMemoryException beyond it. MaximumConcurrentRenderings, one per processor by default, limits how many run at the same time. Further renderings wait, and the wait counts towards the timeout. The heap size is watched from the thread pool: in an app whose other work keeps every thread of the pool busy the watch comes late, and V8 ends the process where it runs out of memory.

The engines stay loaded for the next renderings. In a container, MaximumConcurrentRenderings times MaximumHeapSize has to fit its memory limit beside the app's own memory, with room to spare, since a rendering passes the heap size a little before it ends.

builder.Services.AddMicromarkV8(configure: options =>
{
    options.MaximumConcurrentRenderings = 2;
    options.MaximumHeapSize = 64 * 1024 * 1024;
});

Third-party notices

The JavaScript file bundles micromark and its dependencies, all under the MIT license. Their versions and license texts are in THIRD-PARTY-NOTICES.txt, which comes with the package and which an app serves beside the file at _content/SpatialFocus.Blazor.Micromark/THIRD-PARTY-NOTICES.txt. Each server package holds the notices of its own bundle.

License

The package is released under the MIT license.


Made with ❤️ by Spatial Focus

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed.  net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.1 49 11/30/2026
0.1.0 70 11/30/2026
0.1.0-beta.1 53 11/30/2026