展示HN:Rocal.dev – 构建优先支持离线的Web应用程序
嘿,HN,我正在构建 Rocal——一个基于 Rust 和 WASM 的网页框架,帮助你构建离线优先的应用程序,完全不需要服务器。可以把它想象成后端和前端合并成一个本地体验——一切都在浏览器中运行。
这里是引发这一切的帖子:“抛弃服务器:使用本地优先架构构建离线准备的应用程序”([链接](https://dev.to/picolt/ditch-the-server-build-offline-ready-apps-with-local-first-architecture-1lhn))
一点背景故事:我曾为小型企业构建一个 POS(销售点)系统,而这些企业的互联网连接不可靠。我意识到,即使是基本操作——比如将商品添加到购物车或保存交易——也过于依赖网络请求。这时我决定改变模型,构建一个默认以本地优先为基础的架构。
它的工作原理如下:
- **浏览器中的 WASM + SQLite**:应用程序编译为 WebAssembly,完全在客户端运行,包括一个本地嵌入的 SQLite 数据库。存储或查询数据时无需服务器往返。
- **无需外部 API**:"后端" 逻辑用 Rust 编写并编译以在浏览器中运行。你可以把它看作是一个打包到客户端的单体应用。
- **默认离线工作**:从数据存储到路由和渲染,所有操作都在本地进行。即使用户在会话中断开连接,应用也不会崩溃。
- **可选同步**:如果你希望后期实现云同步(用于备份、多设备或分析),可以在核心应用离线工作后再添加这一层。
这里没有传统意义上的“服务器”。你用 Rust 编写 UI、逻辑和数据模型。Rocal 框架通过 WASM 处理渲染、路由、持久化和本地执行。
我知道这听起来很疯狂,但它在 POS 系统、表单密集型应用和其他延迟或连接性问题的用例中运作良好。想想自助服务终端应用、现场工具或用于偏远地区的应用。
这里有一个快速的演示和架构说明(更多演示即将推出):[链接](https://demo1.rocal.app)
Rocal 完全开源,目前仍处于早期阶段。我正在积极构建 CLI、版本控制系统和开发工作流程,以便更容易地发布这样的应用。从长远来看,我希望构建和部署本地优先的网页应用程序能像启动一个典型的全栈应用一样简单。GitHub:[链接](https://github.com/rocal-dev/rocal)
如果你对构建感觉即时、具有韧性和完全私密的应用程序感兴趣,我很想听听你的想法和反馈。
谢谢!
查看原文
Hey HN, I’m building Rocal — a Rust + WASM web framework that helps you build offline-first apps without needing a server at all. Think of it like the backend and frontend merged into one local experience—everything runs in the browser.<p>Here’s the post that kicked this off: “Ditch the Server: Build Offline-Ready Apps with Local-First Architecture” (<a href="https://dev.to/picolt/ditch-the-server-build-offline-ready-apps-with-local-first-architecture-1lhn" rel="nofollow">https://dev.to/picolt/ditch-the-server-build-offline-ready-a...</a>)<p>A bit of backstory: I was building a POS (point-of-sale) system for small businesses where internet connection is unreliable. I realized that even basic actions—like adding items to a cart or saving a transaction—depended too much on network requests. That’s when I decided to flip the model and build an architecture that’s local-first by default.<p>Here’s how it works:<p>WASM + SQLite in the Browser – The app is compiled to WebAssembly and runs completely client-side, including a local embedded SQLite database. No server round trips needed to store or query data.<p>No External API Needed – The "backend" logic is written in Rust and compiled to run in the browser. You can think of it as a monolith that's shipped to the client.<p>Works Offline by Default – Everything from data storage to routing and rendering happens locally. Even if the user loses connection mid-session, the app doesn’t break.<p>Optional Syncing – If you want cloud sync later (for backup, multi-device, or analytics), that can be layered on top after your core app works offline.<p>There’s no "server" in the traditional sense. You write your UI, logic, and data models in Rust. The Rocal framework handles rendering, routing, persistence, and local execution via WASM.<p>I know it sounds wild, but it’s working well for POS systems, form-heavy apps, and other use cases where latency or connectivity is a problem. Think kiosk apps, field tools, or apps meant for remote areas.<p>Here’s a quick demo and explanation of the architecture (more demos coming soon): <a href="https://demo1.rocal.app" rel="nofollow">https://demo1.rocal.app</a><p>Rocal is fully open-source and still in early stages. I’m actively building the CLI, versioning system, and dev workflow to make it easier to ship apps like this. Long-term, I want to make it as simple to build and deploy local-first web apps as it is to spin up a typical full-stack app. GitHub: <a href="https://github.com/rocal-dev/rocal">https://github.com/rocal-dev/rocal</a><p>If you’re curious about building apps that feel instant, resilient, and fully private, I’d love your thoughts and feedback.<p>Thanks!