This project demonstrates using Enhance to serverside render components in C# dotnet.
Download the latest release of the compiled wasm:
curl -L https://github.com/enhance-dev/enhance-ssr-wasm/releases/download/v0.0.4/enhance-ssr.wasm.gz | gunzip > wasm/enhance-ssr.wasm
- Run Server
dotnet watch
This example demonstrates a way to read elements from a folder and pass them to the Enhance SSR function as JSON. The elements can be formated in several ways:
- Plain HTML can be used with .html extension.
- Pure functions (with a .mjs or .js extenstion) should return HTML and have a function signature as follows:
// elements/my-header.mjs
function MyHeader({ html, state }) {
return html`<style>h1 { color: red; }</style><h1><slot></slot></h1><p>Message: ${state?.store?.message || "no message"}</p>`
}