Files
uce/site/examples/uce-starter/views/datastar-example.uce
T
2026-07-30 19:41:52 +00:00

21 lines
749 B
Plaintext

#load "../lib/app.uce"
#load "../lib/datastar.uce"
COMPONENT(Request& context)
{
if(context.get["stream"] == "1")
{
datastar_sse_headers(context);
print(datastar_patch_elements("<div id=\"datastar-example-result\">Server-rendered UCE Datastar fragment</div>"));
return;
}
<>
<h1>Datastar optional example</h1>
<p>Datastar is vendored beside the starter client libraries for future server-rendered islands. It is not loaded globally.</p>
<script type="module" src="<?= app_asset_url("js/datastar.js", context) ?>"></script>
<button class="btn" data-on:click="@get('<?= app_link("datastar-example", context) ?>&amp;stream=1')">Patch a fragment</button>
<div id="datastar-example-result">Waiting for a server patch.</div>
</>;
}