HTML Next · Build

Build an HTML Next component

Write a workshop check-in counter once in HTML, then use it natively or in Vue, React, Preact, Svelte, or Angular.

Write the component

Save this as counter.html: each click counts a guest, and Reset starts the next session.

counter.html
<template component="x-counter">
  <defs>
    <state name="count" type="number" value="0"></state>
    <handler name="increment">
      <set name="count" expr:value="$count + 1"></set>
    </handler>
    <handler name="reset">
      <set name="count" expr:value="0"></set>
    </handler>
  </defs>
  <div>
    <button type="button" on:click="increment">
      Count: {$count}
    </button>
    <button type="button" on:click="reset">Reset</button>
  </div>
</template>

Nothing to convert: the browser runtime loads counter.html as written, or Vite builds it into native DOM factories. Set up HTML Next.

Keep learning

The proposal's component model, bindings, reactivity, and styles chapters are the full authoring reference, including scoped <style> and controller modules.

HTML Next. MIT-licensed tools for universal HTML components. Implementations of the HTML Next proposals, published from nextwebwg/html-next. Prerelease: the proposals are at Stage 0 and may change.