GNU Affero General Public License v3.0

项目介绍

rfwlab/rfw 是一个托管在 GitHub 上的开源项目,主要使用 Go 编写,采用 GNU Affero General Public License v3.0 许可证,目前获得 15 个 Star、0 次 Fork。

仓库全名
rfwlab/rfw
开源许可证
GNU Affero General Public License v3.0
Star 数
15
未关闭 Issue
6

README 摘要

Real-time dashboards and internal tools, written entirely in Go. No JavaScript. No glue code. Documentation 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 synchronization over WebSocket or Warp StreamBus and updates the DOM for you. It is ideal for…

完整内容见 GitHub 原始 README 或本页 。

常见问题

rfw 用什么语言开发?

主要使用 Go 编写,采用 GNU Affero General Public License v3.0 许可证,目前有 15 个 Star。

rfw 可以免费商用吗?

仓库标注的许可证为 GNU Affero General Public License v3.0,商用前请先阅读仓库 LICENSE 文件确认授权范围。

如何获取 rfw 的源码?

可以直接克隆仓库:git clone https://github.com/rfwlab/rfw.git,默认分支为 main;安装与运行步骤见仓库 README。

rfw 最近还在维护吗?

仓库最近一次更新为 2 周前,当前有 6 个未关闭 Issue;Star 数为 15,可作为社区活跃度的参考。

关于

rfw (Reactive Framework) is a Go-based reactive framework for building web applications using WebAssembly, with future plans to support native applications and the use of GL libraries.

描述取自 GitHub 官方 API,中文内容由 GitRead 中文社区 编辑团队整理。

简要分析

热度分
16
价值分
8
活跃状态
活跃

语言占比

Go
Go Template
HTML
JavaScript
Ruby
Shell
Svelte
Swift

Release

README

Logo

Real-time dashboards and internal tools, written entirely in Go. No JavaScript. No glue code.

rfw counter demo with live updates

Documentation

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 synchronization over WebSocket or Warp StreamBus and updates the DOM 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.26.9 or a newer patched toolchain (1.27.2+ on Go 1.27). 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 WebSocket or Warp StreamBus over WebTransport. The transport is selected through rfw.json or RFW_TRANSPORT without changing application code.

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.

评论

暂无评论