Skip to content

alacris-go

Web components from Go and templ. Typed wrappers generated from your components, the runtime served from Go, a Material Design 3 system in the module, and server-driven props with no HTML on the wire.

alacris is a ~6 kB web component library built on signals and fine-grained DOM updates. alacris-go is the server half. It renders the elements, gets the props across the boundary, generates typed Go wrappers from your components, and can make the server authoritative over what those components show.

Go in, an element out
return alacris.E("user-card").
Prop("name", "Ada").
Prop("age", 36).
Prop("tags", []string{"math", "code"})
renders verified by go test
<user-card name="Ada" age="36" tags="[&#34;math&#34;,&#34;code&#34;]"></user-card>
which the browser turns into the real runtime, upgrading that markup

Props are kebab-cased and encoded by their Go type.

A prop is a signal on the other side. When the server changes something, it writes one property, which wakes one binding, which updates one DOM node.

sess.Element("board").Set("items", list.Items())

No HTML on the wire. Focus, scroll position and half-typed text survive, because no node is replaced.

Render

An Element that implements templ.Component. Props cross as attributes, objects and arrays included, so the page is complete before any JavaScript has run.

Generate

alacris-go generate reads your define() calls and writes typed Go wrappers, typed event details and slot constants. One source of truth.

Go live

Push prop changes over SSE, receive component events over POST.

No npm required

The alacris runtime is vendored into the Go module and served from Go. A Go project needs no JavaScript toolchain to ship.

A design system

Alacris UI ships in the module: sixty-eight Material Design 3 components, typed wrappers, and a theme engine. Config.UI turns it on without a second toolchain.

Terminal window
go get github.com/bmartel/alacris-go
mux.Handle("/_alacris/", alacris.RuntimeHandler())

Start here covers what the server can and cannot render. The runnable example is a live Kanban board:

Terminal window
go run ./examples/todo

The shadow content of a component is built by setup() in the browser. There is no server-side rendering of component internals and no declarative shadow DOM. What Go renders is the element, its props and its light-DOM slot children. See Limitations before you commit to it.