This project demonstrates using Enhance to serverside render components in Rust.
Download the latest release of the compiled wasm:
curl -L https://github.com/enhance-dev/enhance-ssr-wasm/releases/download/v0.0.3/enhance-ssr.wasm.gz | gunzip > wasm/enhance-ssr.wasm
- Run Server
cargo run
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>`
}