Logo
### Real-time dashboards and internal tools, written entirely in Go. No JavaScript. No glue code. ![rfw counter demo with live updates](docs/assets/hero-counter.gif) [Documentation](./docs/articles/index.md)

rfw is “Phoenix LiveView for Go”. It lets you build interactive, real-time web apps using Server Side Computed (SSC) components.

Instead of writing a REST API and a frontend framework, you write Go. rfw handles the WebSocket synchronization and DOM updates for you. It is ideal for:
- Real-time dashboards
- Internal admin tools
- Control planes
- Any app where server state needs to reflect instantly in the UI

Why rfw?

If you are using templ + htmx (or datastar), you are already moving toward server-driven UI. rfw takes this further by providing a full state-synchronization engine. You get the productivity of a frontend framework (like React or Vue) but with the simplicity of a single Go binary and type-safe end to end.

rfw 2.1 includes:

  • batched signals, memo values, asynchronous resources, Suspense, and
    component lifecycle scopes;
  • typed SSC actions and forms with authorization, limits, ordered delivery,
    and resumable sessions;
  • route loaders, names, redirects, metadata, and scroll restoration;
  • component-owned events, Portal, KeepAlive, Transition, DOM hooks, and a
    browser testkit.

Getting Started

rfw requires Go 1.25 or newer. Coming from Node and never installed Go? See
Getting started from Node.

go install github.com/rfwlab/rfw/v2/cmd/rfw@latest
rfw init github.com/user/app
cd app
rfw dev

rfw init takes a Go module path and creates the project in a directory named
after its last segment (app here). The scaffold is a working hello world: a
page, a component, and an RTML template. The component
(components/app_component.go):

//go:build js && wasm

package components

import (
	_ "embed"

	"github.com/rfwlab/rfw/v2/core"
)

//go:embed templates/app_component.rtml
var appComponentTpl []byte

type AppComponent struct {
	*core.HTMLComponent
}

func NewAppComponent() *AppComponent {
	c := &AppComponent{
		HTMLComponent: core.NewHTMLComponent("AppComponent", appComponentTpl, nil),
	}
	c.SetComponent(c)
	c.Init(nil)
	return c
}

Its template (components/templates/app_component.rtml):

<root>
  <div class="p-4">
    <h1 class="text-2xl font-bold">Hello from app!</h1>
    <p>Edit the component to get started.</p>
  </div>
</root>

Templates use RTML directives, not Go html/template syntax: @store:module.store.key
binds reactive state, @on:click:handler binds events, @for ... @endfor renders
lists, and @if ... @endif renders conditionally. The scaffold also wires an SSC
host component whose values render through {h:name} placeholders.

For a full walkthrough, build the
real-time dashboard in 30 minutes.

By default the development server listens on port 8080. Override it with
the --port flag or the RFW_PORT environment variable:

RFW_PORT=3000 rfw dev

Control the SSC host’s log verbosity with the RFW_LOG_LEVEL environment
variable. Possible values are debug, info, warn, and error (default is
info):

RFW_LOG_LEVEL=debug rfw dev

Used by

  • The rfw documentation site: the docs under docs/articles, built and served with rfw itself.
  • FVS Hub: the dashboard of the FVS version control suite (fvs-lab).

Using rfw in production or in a side project? Open a PR and add yourself here.

Server Side Computed (SSC)

SSC is the core of rfw. Most application logic runs on the server, while the browser loads a lightweight binary to hydrate the HTML. The server and client keep state synchronized through a persistent WebSocket connection.

Components use host signal types (t.HInt, t.HString, etc.) to declare server-synced bindings. See the SSC guide for more details.

Testing

Run all tests with:

go test ./...

Continuous Integration runs the same command on every push. See the testing guide for more details.

Build-level Plugins

rfw exposes a simple plugin system for build-time tasks. The CLI
automatically detects PreBuild, Build and PostBuild methods on plugins
and invokes them when present. Each plugin must still provide a file-watcher
trigger via ShouldRebuild and a numeric Priority to determine execution
order.

Tailwind CSS

rfw includes a build step for Tailwind CSS using the official standalone CLI.
Place an input.css file (commonly under static/) containing the @tailwind directives in your project. During development the server watches
template, stylesheet and configuration files and emits a trimmed tailwind.css
containing only the classes you use, without requiring Node or a CDN.

File-based Routing

The built-in pages plugin scans a pages/ directory and automatically
registers routes based on its structure. Each Go file maps to a URL path:

pages/
  index.go        // -> /
  about.go        // -> /about
  posts/[id].go   // -> /posts/:id

Every file must expose a constructor using the PascalCase form of its path,
such as func About() core.Component. The plugin generates a temporary
routes_gen.go that calls router.RegisterRoute for each page during the
build. Import the generated package to execute the registrations, typically
via a blank import in your entrypoint:

import _ "your/module/pages"

For more details and best practices, see the Pages Plugin guide.


rfw uses WebAssembly (Wasm) to bridge the server-client gap, but you only ever write Go.

Explore the SDK

assets

Full API reference for the assets package.

main

Full API reference for the main package.

build

Full API reference for the build package.

commands

Full API reference for the commands package.

initproj

Full API reference for the initproj package.

logging

Full API reference for the logging package.

plugins

Full API reference for the plugins package.

bundler

Full API reference for the bundler package.

copy

Full API reference for the copy package.

docs

Full API reference for the docs package.

env

Full API reference for the env package.

pages

Full API reference for the pages package.

seo

Full API reference for the seo package.

tailwind

Full API reference for the tailwind package.

test

Full API reference for the test package.

server

Full API reference for the server package.

utils

Full API reference for the utils package.

core

Full API reference for the core package.

dom

Full API reference for the dom package.

virtual

Full API reference for the virtual package.

events

Full API reference for the events package.

foundation

Full API reference for the foundation package.

host

Full API reference for the host package.

hostclient

Full API reference for the hostclient package.

http

Full API reference for the http package.

input

Full API reference for the input package.

safehttp

Full API reference for the safehttp package.

markdown

Full API reference for the markdown package.

math

Full API reference for the math package.

highlight

Full API reference for the highlight package.

routeranalytics

Full API reference for the routeranalytics package.

router

Full API reference for the router package.

rpc

Full API reference for the rpc package.

rtmlast

Full API reference for the rtmlast package.

rtmleval

Full API reference for the rtmleval package.

ssc

Full API reference for the ssc package.

state

Full API reference for the state package.

testkit

Full API reference for the testkit package.

types

Full API reference for the types package.