datapages README

The project's README from github.com/romshark/datapages. As one markdown file: README.md.

Datapages

CI golangci-lint Coverage Status Go Reference License: MIT Beta

[!NOTE] Beta: Datapages is ready for production use. APIs are close to stable but can still change.

A Templ + Go + Datastar web framework and toolset for building GUI apps and web application in pure Go - no matter whether it's a real-time collaborative dynamic web app, a simple HTMX-style website, or an installable local-first GUI app.

See FAQ.md for frequently asked questions.

Utilize AI agents more efficiently

Datapages will provide your coding agents with the skills and CLI tools they need to generate well performing, resource-efficient apps and keep the code base coherent and maintainable, lowering token-usage, reducing potential for bugs and vulnerabilities as well as slowing the accumulation of technical debt.

Focus on your business logic

Datapages parses your app source packages, lints them, reports errors, and generates all the wiring and boilerplate. Routing, sessions and authentication, SSE streams, per-tab server-side state, CSRF protection, type-safe URL and action helpers, Prometheus metrics, JavaScript service workers etc. - so your application code stays clean and takes full advantage of Go's strong static typing and high performance.

Examples

Getting Started

See the Guide.

Specification

See SPECIFICATION.md for the full source package specification, including handler signatures, parameters, return values, events, sessions, and modules.

Modules

Datapages ships pluggable modules with swappable implementations:

Motivation

The reason I built Datapages is that the combination of Datastar + Go + Templ is my preferred way of writing server-centric web applications. But in every project I used this tech stack for I kept repeating the same code patterns and solving the same problems over and over again. I realized many developers are repeating the same patterns too and struggle with the common pitfalls:

Your Datastar frontends are your rocket to extraterrestrial worlds of the internet. The further you want to go, the heavier a rocket you'll require. Hence, you need powerful boosters to get it off the ground and overcome Earth's gravity. Such boosters exist in the form of awesome templates like zangster300/northstar, which will quickly get your rocket to the stratosphere and beyond. But power alone is not enough — you also need good stabilizing fins and thrust vectoring to keep your rocket steady as it flies. I felt like this part was lacking in the Go ecosystem of Datastar. By enforcing a common structure of types, methods and other conventions with tooling, Datapages provides not only the power but also the stability your rocket needs to stay in flight for long and consume as little brain fuel as possible.

Not only does Datapages allow you to start quickly with datapages init and jump straight into building your application, but it also continuously supports you keeping accidental complexity low by:

Agentic coding is a big topic right now and likely here to stay. But LLMs tend to drift over time and introduce accidental complexity. So for AI to be used more effectively I wanted to provide the skills and instructions necessary for agents to know how to deal with this tech stack and call into Datapages CLI help them when they drift by providing them with useful feedback.

Cost comparison: doing it all yourself, using AI assistance, and Datapages plus AI assistance

Who This Is For

Datapages is a good fit if you:

Contributing

See CONTRIBUTING.md for development setup and commands, and AGENTS.md for code style, testing conventions, commit message format and project structure.

datapages (romshark/datapages)

Searching Database…

这是什么?Datapages 是一个 Web 框架和工具集,让你用纯 Go 在 Templ + Go + Datastar 技术栈上构建 GUI 和 Web 应用——可以是实时协作的 Web 应用、简单的服务端渲染网站,也可以是可安装的本地优先 GUI 应用。
它和我自己动手把 Datastar 和 Go 接起来有什么不同?它会解析你的源代码包,自动生成那些你本来要在每个项目里手动写的接缝代码:路由、SSE 流、每个标签页的服务端状态、CSRF 防护、Prometheus 指标和 service worker——这样你的代码保持干净,还能充分利用 Go 的静态类型。
我想试试,第一条命令是什么?用 datapages init 生成一个应用骨架;开发时 datapages gen 负责生成样板代码,datapages watch 提供热重载,出错信息会直接显示在浏览器预览里。
运行它需要 NATS 或其他基础设施吗?不需要——各个组件都是可插拔的:单实例应用用内存版的会话和消息代理就够,等你要扩展规模时,可以换成基于 NATS 的实现(KV 会话,配合 AES-128-GCM 加密的 cookie)。
README 里说它还是 beta——放到生产环境靠谱吗?它明确表示 Datapages 已经可以用于生产环境,但 API 接近稳定、仍可能变动——在它成熟的过程中,升级时可能需要做一些调整。
那它是用来构建带 REST API 的离线 SPA 的吗?不是——它面向服务端渲染的应用,数据由服务器掌管,而不是本地优先、可离线的 SPA;它还免去了为了给前端喂数据而单独维护一套 REST/GraphQL API 的麻烦。
它能做真正的桌面应用吗,还是只能做 Web 应用?两者都可以做混合型应用:calculator 示例既能作为多客户端服务器运行,也能作为单客户端桌面应用运行,而且应用部署时就是一个静态编译的二进制文件。
作者为什么不直接用 Go 配 Datastar,而要开发这个?Datastar + Go + Templ 本来就是他偏好的技术栈,但他在每个项目里都在重复同样的套路——SSE 处理、NATS 的使用、身份认证、热重载配置。Datapages 把这些方案打包起来,并补上了他在 Go 的 Datastar 生态里觉得缺失的结构稳定性。
它强制采用的 Tao 架构是什么?这是一种以 Datastar Tao 为导向的应用结构,作为合理的默认约定提供——工具会检查其中关于类型和方法的通用约定——同时仍留有超越它的空间。todolist 示例是最符合 Tao 规范的一个。
能配合 Tailwind CSS 或 Web Components 一起用吗?可以——两者都有示例:一个展示 Tailwind CSS 集成的极简静态页面,以及一个落地页,通过自定义 watcher 用 esbuild 打包原生和基于 Lit 的 Web Components。
Creator
romshark
Size
7.5 MB
Stars
114
Age
9mo
Commits · 90 Days