A React-like frontend framework written in Go, compiled to WebAssembly.
  • Go 98.8%
  • JavaScript 0.8%
  • HTML 0.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Agent-Bob a6ce1142c6 feat(table): add MaxWidth column option for text truncation with tooltip
Add Column.MaxWidth field that enables automatic text truncation with
ellipsis and hover tooltip in DataTable cells. When MaxWidth is set:

- Header cell gets max-width inline style
- Data cells get gr-table-td-truncate CSS class (overflow: hidden,
  text-overflow: ellipsis, white-space: nowrap) + max-width inline style
- Plain text cells (without custom Render) get a title attribute
  showing full text on hover
- Custom Render cells still get the truncation CSS on the td wrapper

New CSS class: .gr-table-td-truncate

This enables platform pages to constrain long-content columns
(descriptions, URLs, IDs) without ad-hoc string truncation.
2026-04-11 20:24:04 +08:00
cmd/goreact feat: content-hashed WASM filenames in build pipeline 2026-04-08 07:51:05 +08:00
docs fix: AppShell main content overflow: hidden blocks vertical scrolling 2026-04-10 21:21:34 +08:00
examples enterprise: sidebar group headers + contextual FAB on Users page only 2026-04-09 08:56:10 +08:00
internal feat: content-hashed WASM filenames in build pipeline 2026-04-08 07:51:05 +08:00
pkg feat(table): add MaxWidth column option for text truncation with tooltip 2026-04-11 20:24:04 +08:00
web review: sync stale web/ directory with canonical internal/devserver/web/ 2026-04-08 08:09:24 +08:00
.gitignore refactor(fullstack): restructure layout to cmd/ + internal/ui/ pattern 2026-04-01 22:09:03 +08:00
AGENTS.md fix: AppShell main content overflow: hidden blocks vertical scrolling 2026-04-10 21:21:34 +08:00
Dockerfile refactor: transform project template into go-react framework skeleton 2026-03-29 10:17:41 +08:00
go.mod spike: validate goldmark WASM compilation and VDOM rendering 2026-04-06 10:09:11 +08:00
go.sum spike: validate goldmark WASM compilation and VDOM rendering 2026-04-06 10:09:11 +08:00
Jenkinsfile 更新 Jenkinsfile 2026-03-29 06:57:37 +00:00
Makefile Update Makefile and Jenkinsfile for framework CI 2026-03-29 14:28:07 +08:00
README.md docs: enrichment - add missing README links, Next Steps sections, and example entries 2026-04-08 07:44:41 +08:00

go-react

A React-like frontend framework written in Go, compiled to WebAssembly.

Write frontend web applications in pure Go using React's mental model — functional components and hooks. Your Go code compiles to WASM and runs in the browser. A Vite-inspired dev server provides hot reload for a fast development loop.

Features

  • Type-safe componentsfunc(props MyProps) *Node with compile-time checked props via generics
  • Built-in component library — 30+ components: Button, Card, Alert, Modal, Toast, Tabs, DataTable, AppShell, Sidebar, FAB, and more
  • AI chat components — ChatContainer, UseChat hook, SSE streaming, MockStreamProvider for testing, dark mode, auto-scroll, markdown rendering
  • Rich editors — Markdown editor with preview and JSON editor with tree view, raw editor, toolbar, and inline editing
  • Enterprise layout system — AppShell, AppHeader, AppFooter, Sidebar with collapse, SearchInput with debounce, FilterBar, Skeleton loading, BusyIndicator
  • Form system — Type-safe UseForm hook with validation, connected inputs, three validation modes
  • Data fetching — UseFetch, UseQuery (caching, retry, polling), UseMutation (cache invalidation)
  • Browser API hooks — UseClipboardAction, UseTimeout, UseInterval, UseWindowSize, UseOnline, UseMediaQuery, UseDocumentTitle, UseIntersection, UseResize, UseConsole with testable mocks
  • 83 SVG icons — Pure Go icon functions in 6 tree-shakeable categories
  • CSS transitions — Animated mount/unmount with 7 built-in presets
  • Dark mode & theming — ThemeProvider, UseTheme hook, system preference detection, localStorage persistence, zero re-renders
  • Full hooks systemUseState, UseEffect, UseMemo, UseCallback, UseRef, UseContext, UseReducer
  • Virtual DOM with reconciliation — Efficient diffing and patching, keyed list support
  • Zustand-style global store — Type-safe reactive state management with UseStore hook
  • Client-side router — Path params, nested routes, hash-based and history-based routing
  • Type-safe element DSLel.Div(), el.Button(), etc. — compile-time checked, no JSX
  • CSS utility system — Tailwind-inspired gr- prefixed classes with theme tokens and design system
  • Error boundaries — Catch render panics with typed fallback components
  • Full-stack support — Single-command dev server manages backend + frontend; single binary deployment with embedded WASM frontend via embed.FS
  • Testable without a browser — All components testable with go test using an in-memory mock DOM
  • Testing librarygrtest provides GetByText, Click, Type, snapshot testing
  • Vite-inspired dev server — File watching, WASM recompilation, WebSocket hot reload with state preservation
  • CLI toolgoreact dev, goreact build, goreact create

Quick Start

# Install the CLI
go install codeberg.org/theosun/go-react/cmd/goreact@latest

# Create a new project
goreact create my-app
cd my-app

# Start the dev server
goreact dev

Open http://localhost:3000 — you have a running Go/WASM app with hot reload.

Full-Stack Quick Start

# Create a fullstack project (Go backend + WASM frontend)
goreact create --fullstack my-app
cd my-app

# Start both backend and frontend with one command
goreact dev
# → Backend on :8081, frontend on :3000, both with hot reload

# Build for production (single binary)
goreact build
./bin/server

📚 Documentation

Getting Started

Batteries Included

  • Batteries Overview — Tour of all batteries-included features
  • Component Library — 12 foundation UI components
  • Markdown Editor & Preview — Markdown parser, preview component, and split-pane editor
  • JSON Editor — JSON tree view, raw editor, toolbar, inline editing, and cookbook patterns
  • Interactive Components — Modal, Toast, Tabs, Accordion, Dropdown, Tooltip
  • Enterprise Components — AppShell, Sidebar, SearchInput, FilterBar, DataTable, Skeleton, BusyIndicator, FAB
  • Forms — Type-safe form state, validation, and form-connected inputs
  • Data Fetching — UseFetch, UseQuery, UseMutation with caching and retry
  • Browser APIs — UseClipboardAction, UseTimeout, UseInterval, UseWindowSize, UseOnline, and more with testable mocks
  • Browser API Cookbook — Copy-to-clipboard, debounced search, infinite scroll, responsive layout, and more recipes
  • Icons — 83 SVG icons as pure Go functions
  • CSS Transitions — Enter/exit animations with 7 built-in presets
  • Chat Components — ChatContainer, UseChat hook, streaming, MockStreamProvider, testing guide
  • Chat Streaming Architecture — SSE streaming, StreamProvider interface, MockStreamProvider for tests

Guides

Reference

Tutorials

Migration

Examples

The examples/ directory contains complete applications:

  • Counter — Minimal app demonstrating UseState and events
  • Todo — Store-based state management with CRUD operations
  • Showcase — Multi-page app with routing, store, CSS, and 40+ tests
  • Fullstack — Go backend + WASM frontend as a single binary
  • Toodoo — Full-stack todo app with SQLite backend, REST API, MockClient testing, and 40+ tests
  • Batteries — Comprehensive demo of all batteries-included features: components, forms, data tables, icons, transitions, error boundaries (43 tests)
  • Chat — Full-stack AI chat with SSE streaming, markdown rendering, and 20+ tests
  • Enterprise — Enterprise dashboard with AppShell, Sidebar, DataTable, SearchInput, and dark mode
# Run an example (frontend-only)
goreact dev --dir ./examples/showcase

# Run the fullstack example
cd examples/fullstack && goreact dev

# Run showcase tests (no browser needed)
go test ./examples/showcase/... -v

Architecture

Downstream App (Go)
     │
     │  func App(props) *Node
     │  hooks, store, router, elements
     ▼
┌──────────────────────────────────────────┐
│  go-react framework (pkg/)               │
│                                          │
│  vdom ──▶ reconciler ──▶ renderer ──▶ DOM│
│  hooks    store    router    css    el   │
└──────────────────────────────────────────┘
     │                          │
  dom/jsdom (WASM)         dom/mock (tests)
     │                          │
  syscall/js              in-memory tree
     │
  Browser DOM

Requirements

  • Go 1.24+
  • A modern browser with WebAssembly support

Development

goreact dev           # Start dev server with hot reload (frontend-only or fullstack auto-detected)
goreact build         # Build for production (auto-detects project type)
make test             # Run all tests (no browser needed)
make precommit        # fmt + vet + test + build (run before every commit)
make build            # Build CLI tool (for framework development)
make build-wasm       # Build WASM examples (for framework development)

License

[Add license here]