<link rel="stylesheet" href="/fonts.css" />
Go • Zero JS • Vue SFC syntax

Server-side component
rendering for Go

Write reusable HTML components in .vue files. Render them server-side in Go — no Node.js, no JavaScript runtime, no virtual DOM.

go install github.com/dhamidi/htmlc/cmd/htmlc@latest

Zero JavaScript runtime

Templates evaluate once per request and produce plain HTML. No hydration, no virtual DOM, no client bundles.

Vue SFC syntax

Author components using the same .vue format you already know — v-if, v-for, v-bind, slots, scoped styles.

CLI & Go API

Use the htmlc CLI for static sites or import the Go package to render components inside any HTTP handler.

Scoped styles

<style scoped> rewrites selectors and injects scope attributes automatically — styles never leak between components.

Static site generation

htmlc build walks a pages directory and renders every .vue file to a matching .html file. Props come from sibling JSON files.

Debug mode

Pass -debug and the output is annotated with HTML comments showing which component rendered each subtree.

Embed in any Go application

Import the package, create an engine, and render components directly from your HTTP handlers.

1. Add the dependency
go get github.com/dhamidi/htmlc
2. Write a component
<!-- templates/Greeting.vue -->
<template>
  <p>Hello, {{ name }}!</p>
</template>
3. Create an engine & render
engine, err := htmlc.New(htmlc.Options{
    ComponentDir: "templates/",
})

html, err := engine.RenderFragmentString(
    "Greeting",
    map[string]any{"name": "world"},
)
// html == "<p>Hello, world!</p>"
4. Serve over HTTP
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
    w.Header().Set("Content-Type", "text/html; charset=utf-8")
    engine.RenderPage(w, "Page", map[string]any{
        "title": "Home",
    })
})