chore: add webui-todo-app example with declarative FAST HTML and webui prerendering#7362
Draft
chore: add webui-todo-app example with declarative FAST HTML and webui prerendering#7362
Conversation
…ndering
Adds a new example in examples/webui-todo-app that:
- Converts the todo-app to use declarative FAST HTML syntax (f-template,
f-repeat, {{}}/{} bindings) via @microsoft/fast-html
- Prerenders the DOM content using @microsoft/webui (build + render)
- The Express server calls build() at startup to compile the HTML template
into a binary protocol, then render() on each request to inject
prerendered todo items and component templates as raw HTML
- Client-side hydration uses RenderableFASTElement and TemplateElement
from @microsoft/fast-html, seeded with window.__INITIAL_STATE__
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
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.
Summary
Adds a new
examples/webui-todo-appthat fulfills the integration-with-webui requirements:todo-appto use@microsoft/fast-htmldeclarative templates (<f-template>,<f-repeat>,{{}}/{}bindings) instead of imperativehtmltagged template literals@microsoft/webui: An Express server usesbuild()at startup to compile the HTML template into a binary protocol, thenrender()on each request to inject prerendered todo items and component template definitions as raw HTMLtodo-app: add todos, filter (all/active/completed), mark done, remove itemsArchitecture
Server-side (
server.js)build({ appDir: './src', plugin: 'fast' })compilessrc/index.htmlat startuprender(protocol, { prerenderedItems, componentTemplates })injects:{{{prerenderedItems}}}— raw HTML of todo<li>items, visible before JS loads{{{componentTemplates}}}—<f-template>definitions for client-side hydrationwindow.__INITIAL_STATE__so the client hydrates with the same dataTemplate (
src/index.html)<todo-app defer-hydration>with<template shadowrootmode="open">DSD — prerendered content shows immediately{{{prerenderedItems}}}placeholder in the shadow DOM<ul>for webui to fill{{{componentTemplates}}}placeholder for<f-template>injection after the elementClient (
src/main.ts)RenderableFASTElementmixin withtemplateOptions: "defer-and-hydrate"TemplateElement.define({ name: 'f-template' })registers the template processorTodoList.provide(document, new DefaultTodoList(window.__INITIAL_STATE__))seeds stateDeclarative
<f-template>bindings (single-brace{}, client-only)