MoonZoon

MoonZoon

Rust全栈框架 重新定义Web开发

MoonZoon是一款创新的Rust全栈框架,致力于简化Web开发流程。该框架摒弃了传统Web技术,仅使用Rust语言实现前后端开发。MoonZoon提供高效、简洁且可扩展的解决方案,支持SEO优化、身份验证和离线功能。其设计理念有效减少了技术决策负担,使开发者能更专注于核心业务逻辑。

RustMoonZoon全栈框架Web开发ActixGithub开源项目
<p align="center"> <img src="branding/MoonZoon_logo_both_texts_light_on_black.svg" width="630" title="MoonZoon logo"> </p> <p align="center"> <a href="https://discord.gg/eGduTxK2Es"> <img src="https://discordapp.com/api/guilds/797429007683158046/widget.png?style=banner2" title="MoonZoon Discord"> </a> </p>

"We don't want to lose time and money due to millions of unnecessary technical micro-decisions."


MoonZoon is a Rust Fullstack Framework.

<table> <td> <ul> <li>NO Javascript</li> <li>NO CSS</li> <li>NO HTML</li> <li>NO REST</li> <li>NO GraphQL</li> <li>NO SQL</li> <li>NO Analysis Paralysis</li> <li>NO Wheel Reinventing</li> <li>NO Passwords*</li> </ul> </td> <td> <ul> <li>Rust</li> <li>Fast</li> <li>Simple</li> <li>Scalable</li> <li>SEO</li> <li>Auth</li> <li>MoonZoon CLI</li> <li>Easy Deploy</li> <li>Offline Support</li> </ul> </td> </table>

* Authentication methods are described in Backend.md


Code example

<p align="center"> <img src="docs/images/counter_demo.gif" width="559" title="MoonZoon logo"> </p>
use zoon::*; fn main() { start_app("app", root); } static COUNTER: Lazy<Mutable<i32>> = lazy::default(); fn root() -> impl Element { Row::new() .s(Align::center()) .s(Gap::new().x(15)) .item(counter_button("-", -1)) .item_signal(COUNTER.signal()) .item(counter_button("+", 1)) } fn counter_button(label: &str, step: i32) -> impl Element { let (hovered, hovered_signal) = Mutable::new_and_signal(false); Button::new() .s(Width::exact(45)) .s(RoundedCorners::all_max()) .s(Background::new() .color_signal(hovered_signal.map_bool(|| color!("#edc8f5"), || color!("#E1A3EE", 0.8)))) .s(Borders::all( Border::new() .width(2) .color(color!("oklch(0.6 0.182 350.53 / .7")), )) .on_hovered_change(move |is_hovered| hovered.set(is_hovered)) .label(label) .on_press(move || *COUNTER.lock_mut() += step) }

Demos

New Project Template on Netlify | Template

[Production apps in development]

  • @TODO Add once the apps are ready to show.

Chat


Create & Run project

  1. Install the latest stable Rust. (Or upgrade with rustup update stable.)

  2. Install the web assembly target rustup target add wasm32-unknown-unknown

  3. cargo install mzoon --git https://github.com/MoonZoon/MoonZoon --locked

  4. mzoon new my_counter

  5. cd my_counter

  6. mzoon start --open

    mzoon start --open


Deploy project

Both Frontend & Backend

I use Coolify on Hetzner with this Dockerfile:

FROM rust:1 WORKDIR /app RUN rustup target add wasm32-unknown-unknown # NOTE: Set `--rev` to the commit you use in your project RUN --mount=type=cache,target=/usr/local/cargo,from=rust,source=/usr/local/cargo \ cargo install mzoon --git https://github.com/MoonZoon/MoonZoon --rev ccc15d043e78a6656d68a60d46de1f540724e093 --locked COPY . . RUN --mount=type=cache,target=/usr/local/cargo,from=rust,source=/usr/local/cargo \ --mount=type=cache,target=target \ /usr/local/cargo/bin/mzoon build -r RUN --mount=type=cache,target=target \ ["cp", "./target/release/backend", "/usr/local/bin/moon_app"] ENTRYPOINT ["moon_app"]

MoonZoon app was successfully deployed to other services like Heroku (buildpack), Clever Cloud, CapRover or Fly.io.

MoonZoon Cloud is planned as well.

Frontend-only

  1. mzoon build --release --frontend-dist netlify

    • Hosting name (netlify) is optional. It creates files like netlify.toml.
  2. [optional] Test it with a dev server like miniserve:

    cargo install miniserve miniserve --port 8079 --index index.html --spa frontend_dist
  3. Drag & drop the frontend_dist directory to Netlify.

    moonzoon-new-project on Netlify


Examples


Blog

Dev News

  1. CLI, Build pipeline, Live-reload, HTTPS [dev.to / MD]

  2. Live demo, Zoon, Examples, Architectures [dev.to / MD]

  3. Signals, React-like Hooks, Optimizations [dev.to / MD]

  4. Actix, Async CLI, Error handling, Wasm-pack installer [dev.to / MD]

  5. Chat example, MoonZoon Cloud [dev.to / MD]


Documentation

1. Philosophy & Non-Goals.md

2. Frontend.md

3. Backend.md

4. CLI.md

5. Cloud.md

6. Development.md


Size & Speed

Benchmark example size

Benchmark example speed


FAQ

  1. "Why another framework? Are you mad??"

    • I want to write products. Reliable products. Quickly. I want to enjoy the development. I don't want to play endlessly with tools, protocols and config files.
  2. "Is it production-ready? / What's the current progress?"

    • The frontend part is almost ready. If you have a custom backend or don't need backend at all then you can start writing your new frontend app right now! And then deploy it wherever you want. I assume there'll be two bigger breaking changes - to improve color system (related issue) and to improve event handlers - but the Rust compiler should make the future migration simple.

    • Realtime communication between frontend and backend works but neither virtual actors nor native database adapters have been implemented yet. However, Actix API has been exposed to overcome these current limitations so you can treat the MoonZoon backend API as Actix with realtime messaging. I've successfully integrated Postgres (through SeaORM) into a MoonZoon app developed for my client and I plan to integrate BonsaiDb to my another production app. Bonsai could be integrated as a scalable database and file storage into MoonZoon when I'll find it a suitable choice.

    • Subscribe to #news channel on our Discord server to find out when MoonZoon is ready for your project. Or just let us know what blocks you from starting to develop with MZ.

  3. "Who is developing it?"

  4. "Could I help somehow? / Where can I find more information?"

    • Join our Discord chat and don't hesitate to ask any questions or present your ideas.
    • Create a pull-request if you want to fix typos, dead links, weird Czech-English sentences, etc.
    • If you think MoonZoon will be useful for your project, I want to know that! (Use chat or martin@moonzoon.rs).
    • Don't hesitate to tell your friends about MoonZoon and feel free to share the link (http://moonzoon.rs) on social platforms / forums / blogs / newsletters.
  5. "Why Rust?"

    • It's the best language.

      <details> <summary>Longer explanation</summary>

      I've written commercial or hobby projects in multiple languages (Js, CoffeeScript, TS, Elm, Elixir, PHP, C, C++, C#, Go, ..). However I want to write only in Rust.

      Rust is hard to learn even for experienced developers because they have to unlearn many things and adapt thought process to Rust concepts and best practices. However, once you stop fighting the compiler, Rust takes your hand and push you to correct and efficient solutions.

      I had similar feeling when I was learning to drive a car - it seems to be pretty difficult/strange from the start but once you get used to it, you know that each control / button / pedal has it's specific place and purpose for a good reason. And it makes even more sense when you learn low-level stuff - e.g. how the transmission and a clutch work.

      Steep learning curve also brings some benefits:

      • It means that Rust doesn't hide real complexity behind too simple models.
      • It's almost impossible for complete beginners to publish incomplete/buggy libraries.

      _

      Rust is designed so well that I feel nervous while I'm writing in other languages - I have to do compiler's work again in my head and think about weird things like typos in code, nulls, undefineds, memory leaks, accidental mutations, how to write fast code without mutability, etc. It generates significant cognitive load so I can't focus so much on business logic and other important stuff.

      I don't believe you should use the most suitable language for a specific domain or problem at all costs. I think consistency among your / company projects, productivity and simplicity should have the highest priority. And Rust is a very universal language so I think it's a good choice for almost all cases.

      There are also things that should be improved (and are improving):

      1. Compilation is still slow, but it's not so frustrating now.
      2. IDE support still isn't very good because of Rust complex types and macros but thanks to Rust Analyzer it's getting better every day.
      3. target folder (it's something like node_modules) can be pretty big.
      4. It's a bit difficult to combine sync and async world in some cases and choose the best async runtime and error handling libraries. Also async drop would be nice.
      5. #[derive(xx)] and cargo install may have a bit surprising behavior.
      6. It may be a bit difficult to pick compatible dependencies.

      So there is still room for improvements but even now I'm the most productive in Rust.

      </details>

Thank you for reading! We are waiting for you on

编辑推荐精选

扣子-AI办公

扣子-AI办公

职场AI,就用扣子

AI办公助手,复杂任务高效处理。办公效率低?扣子空间AI助手支持播客生成、PPT制作、网页开发及报告写作,覆盖科研、商业、舆情等领域的专家Agent 7x24小时响应,生活工作无缝切换,提升50%效率!

堆友

堆友

多风格AI绘画神器

堆友平台由阿里巴巴设计团队创建,作为一款AI驱动的设计工具,专为设计师提供一站式增长服务。功能覆盖海量3D素材、AI绘画、实时渲染以及专业抠图,显著提升设计品质和效率。平台不仅提供工具,还是一个促进创意交流和个人发展的空间,界面友好,适合所有级别的设计师和创意工作者。

图像生成AI工具AI反应堆AI工具箱AI绘画GOAI艺术字堆友相机AI图像热门
码上飞

码上飞

零代码AI应用开发平台

零代码AI应用开发平台,用户只需一句话简单描述需求,AI能自动生成小程序、APP或H5网页应用,无需编写代码。

Vora

Vora

免费创建高清无水印Sora视频

Vora是一个免费创建高清无水印Sora视频的AI工具

Refly.AI

Refly.AI

最适合小白的AI自动化工作流平台

无需编码,轻松生成可复用、可变现的AI自动化工作流

酷表ChatExcel

酷表ChatExcel

大模型驱动的Excel数据处理工具

基于大模型交互的表格处理系统,允许用户通过对话方式完成数据整理和可视化分析。系统采用机器学习算法解析用户指令,自动执行排序、公式计算和数据透视等操作,支持多种文件格式导入导出。数据处理响应速度保持在0.8秒以内,支持超过100万行数据的即时分析。

AI工具酷表ChatExcelAI智能客服AI营销产品使用教程
TRAE编程

TRAE编程

AI辅助编程,代码自动修复

Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。

AI工具TraeAI IDE协作生产力转型热门
AIWritePaper论文写作

AIWritePaper论文写作

AI论文写作指导平台

AIWritePaper论文写作是一站式AI论文写作辅助工具,简化了选题、文献检索至论文撰写的整个过程。通过简单设定,平台可快速生成高质量论文大纲和全文,配合图表、参考文献等一应俱全,同时提供开题报告和答辩PPT等增值服务,保障数据安全,有效提升写作效率和论文质量。

AI辅助写作AI工具AI论文工具论文写作智能生成大纲数据安全AI助手热门
博思AIPPT

博思AIPPT

AI一键生成PPT,就用博思AIPPT!

博思AIPPT,新一代的AI生成PPT平台,支持智能生成PPT、AI美化PPT、文本&链接生成PPT、导入Word/PDF/Markdown文档生成PPT等,内置海量精美PPT模板,涵盖商务、教育、科技等不同风格,同时针对每个页面提供多种版式,一键自适应切换,完美适配各种办公场景。

AI办公办公工具AI工具博思AIPPTAI生成PPT智能排版海量精品模板AI创作热门
潮际好麦

潮际好麦

AI赋能电商视觉革命,一站式智能商拍平台

潮际好麦深耕服装行业,是国内AI试衣效果最好的软件。使用先进AIGC能力为电商卖家批量提供优质的、低成本的商拍图。合作品牌有Shein、Lazada、安踏、百丽等65个国内外头部品牌,以及国内10万+淘宝、天猫、京东等主流平台的品牌商家,为卖家节省将近85%的出图成本,提升约3倍出图效率,让品牌能够快速上架。

下拉加载更多