datapages README

项目的 README,来自 github.com/romshark/datapages。合并为一个 markdown 文件:README.md。

Datapages

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

Discord Slack

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

Datapages is a web framework and toolchain for Go, Templ and Datastar. It supports collaborative web applications, HTMX-style sites and installable desktop applications.

See FAQ.md for frequently asked questions.

Give coding agents project-specific guidance

datapages init writes instructions and skills for coding agents. datapages lint and datapages gen report invalid application declarations and template calls with file positions and suggested fixes.

Focus on your business logic

Datapages parses and checks the application package, then generates the HTTP wiring. The generated code covers routes, sessions, SSE streams, per-tab state, CSRF protection, typed URL and action helpers, Prometheus metrics and offline service workers. Application code remains Go and Templ.

Examples

Getting Started

See the documentation. Start with the installation and the tutorial.

Specification

SPECIFICATION.md defines handler signatures, parameters, return values, events, sessions and modules.

Modules

Datapages includes modules with replaceable implementations:

Motivation

Go, Templ and Datastar are a direct way to build server-rendered applications. Projects built with them still repeat the same work for routes, SSE streams, NATS, sessions, CSRF protection, development reloads and deployment.

Datapages defines conventions for that repeated work and checks them with the CLI:

These conventions also give coding agents a stable application model. The generated instructions describe the model, and the CLI reports violations with source positions and fixes.

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

Who this is for

Datapages fits projects where:

Contributing

See CONTRIBUTING.md for development setup and commands, DEV.md for the watcher of the documentation pages, and AGENTS.md for code style, testing conventions, commit message format and project structure.

datapages (romshark/datapages)

正在搜索数据库…

这是什么?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。
作者
romshark
大小
17.1 MB
星标
122
时长
10个月
提交 · 90 天