Adds a Blazor WebAssembly (.NET 10) + Motoko Hello World template.#1359
Open
mitnick2012 wants to merge 1 commit into
Open
Adds a Blazor WebAssembly (.NET 10) + Motoko Hello World template.#1359mitnick2012 wants to merge 1 commit into
mitnick2012 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
The icp-cli templates library has no support for .NET/C# developers who want to
build on ICP using Blazor WebAssembly. This template fills that gap by providing
a working starter project that combines Blazor WASM (.NET 10) on the frontend with
a Motoko canister on the backend, using icp-cli for deployment. Without this template,
.NET developers face undocumented pitfalls that make getting started unnecessarily
difficult.
Requirements
Considered Solutions
type="module") for @dfinity/agent — rejected due to browserdeferral behavior causing a race condition where Blazor attempts JS interop before
the module is ready, silently breaking button events.
defer— selected. Compiles @dfinity/agent into asingle plain JS file exposed as
window.IcpAgent. Thedeferattribute guaranteesscript execution order before DOMContentLoaded, so the global is always available
when Blazor makes its first JS interop call.
Recommended Solution
Webpack +
deferloading pattern, modeled after the existingDfinity.Blazorcommunity library. This is the only approach that reliably solves the JS interop
race condition without adding complexity to the Blazor startup sequence. It also
bundles @dfinity/agent locally (no CDN dependency), pins the version in package.json,
and produces a single minified file that the asset canister can certify correctly.
Considerations
templates — no private keys, no hardcoded canister IDs.
This is negligible compared to the Blazor WASM runtime (~5MB+). Brotli compression
via the asset canister reduces the bundle to ~80KB on the wire.
a working starting point without having to discover undocumented pitfalls.
recipe — both of which are maintained by DFINITY. The .NET 10 LTS support window
runs until November 2028, so no forced upgrade in