Nue 2.0 Beta 发布!网页的 Unix。
Nue 2.0 Beta released! The Unix of the web

原始链接: https://nuejs.org/blog/2.0/

## Nue 2.0:精简、快速的 Web 框架 Nuekit 已经完全重建,以速度和简洁性为重点,现在仅专注于 Bun 作为其运行时。这带来了令人瞩目的 1MB 可执行文件,**没有任何外部依赖**,秉承了小型、专注工具的 UNIX 风格理念。 主要更新包括简化的 **HTML 模板系统**,使用文档类型声明(``、`` 等)来定义页面行为——服务器渲染、客户端渲染或库类型,从而无需像 `.dhtml` 这样的文件扩展名。 新功能赋予开发者 **SVG 模板**、自动 **站点地图和 RSS 源生成**,以及由 **Nuestate** 提供支持的新 **SPA 开发模式**——一种以 URL 为先的状态管理系统。**Nueserver** 提供边缘优先的后端能力,并提供服务器代理选项,用于现有后端。 四个新的项目模板(最小化、博客、SPA、完整版)满足不同的需求。最终,Nue 2.0 通过利用 Bun 的速度和浏览器兼容的 API,优先考虑性能、开发者体验和对 Web 标准的遵守。

## Nue 2.0 Beta 发布 - 摘要 Nue 2.0,被描述为“Web 的 Unix”,已发布 Beta 版本 (nuejs.org)。此发布在 Hacker News 上引发讨论,一些人质疑“Unix”的品牌定位,认为它误解了标准化工具的概念。 用户们讨论了 Nue 相对于 Bun 等竞争对手的定位,一些人表示有兴趣,尽管他们已经投资了基于 Node.js 的项目。 许多评论员强调了潜在的迁移挑战。 尽管对品牌和生态系统锁定存在疑虑,但许多人认为 Nue 有前景,赞扬其极简的方法,并称其为“一股新鲜空气”。 开发者提供了一个迁移文档链接,供感兴趣者了解更多信息。 最后,文章底部包含了一个 Y Combinator 申请的号召。
相关文章

原文

What's new

Complete rewrite

Nuekit was rebuilt from scratch with a clear focus: do one thing well. The new architecture serves files directly from your source directory during development. No temporary .dist/dev folder, no build step before you start working. Just create files and see them in the browser.

We also switched from supporting both Bun and Node to Bun only. This decision enables the entire framework to stay lean while delivering better performance.

HTML templating

All HTML files now use the same .html extension. The document type declaration determines how Nue processes each file:

<!-- Server-rendered page -->
<!doctype html>

<!-- Dynamic, client-rendered page -->
<!doctype dhtml>

<!-- Server-side component library -->
<!html lib>

<!-- Client-side library -->
<!dhtml lib>

<!-- Isomorphic library -->
<!html+dhtml>

When you omit the doctype, Nue detects the type automatically based on your markup. If your file has event handlers or imports, it becomes dynamic. If it's pure content structure, it renders server-side.

This replaces the old .dhtml extension system with a more flexible approach that follows HTML standards.

Zero dependencies

Nue 2.0 has no external dependencies. Everything needed to build websites lives in that 1MB executable:

Building without dependencies gives us full control over the entire stack. Each tool does one thing well and communicates seamlessly with the others. This is how you build frameworks the UNIX way: small, focused tools that work together perfectly.

This gives us a lean developer experience without the typical framework bloat.

New features

SVG development - Process SVG files as templates with full HMR support. Embed your design system styles and fonts directly into standalone graphics. Mix HTML and SVG naturally using <html> tags that become <foreignObject> automatically.

Sitemap generation - Enable in your config and Nue generates sitemap.xml automatically from your pages. Skip pages with draft or private flags.

RSS feeds - Point at any content collection and get a complete RSS feed with auto-discovery link tags. Perfect for blogs and documentation sites.

SPA development

Single-page applications get a new development model built on Nuestate. Define your route patterns in one place and let the URL drive your application. Regular <a href> links become SPA navigation automatically with the autolink option.

The upcoming universal data model will unify how data flows through SPAs, but the foundation is here now: clean separation between routing, data model, state, and the UI layer.

New tools

Nuestate - URL-first state management that puts application state in the URL by default. Bookmarking, sharing, and browser navigation work automatically without extra code. No stores, no reducers, no actions. Just read and write to a state object.

Nueserver - Edge-first backend development. Write server code once and run it identically on your machine and across global edge locations.

Server proxy - Not ready for edge-first? Configure Nue to proxy API calls to your existing backend.

New templates

Four options for different needs:

minimal - Just index.html and index.css to start from scratch

blog - Simple Markdown based blog with minimal coding/configuration

spa - Single-page application with a simple server and UI

full - Full stack web with blog, docs, marketing pages, authentication, and SPA

Why Bun

Nue and Bun share the same vision for web development.

Standards based - Bun uses browser APIs you already know: fetch(), Request, Response, URL, Headers, and FormData. No framework-specific APIs to learn. Code that works in the browser works in Bun.

Rich in features - Core features like bundling, serving, and file handling are written in native code (Zig). No need for Vite, ESBuild, or separate build tools.

Performance - Bun is faster than Node

While Node support would be convenient, Bun-only is what enables Nue's extreme performance and simplicity. It's what makes the developer experience special.

联系我们 contact @ memedata.com