whisker README

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

Whisker — Build cross-platform apps in Rust

Build native iOS, Android, desktop, and web apps in Rust with a fine-grained reactive runtime, Taffy layout, and native Host renderers. No virtual DOM.

crates.io Documentation License


use whisker::prelude::*;

#[whisker::main]
fn app() -> Element {
    render! {
        Counter
    }
}

#[component]
fn counter() -> Element {
    let count = signal(0);
    render! {
        View(style: css!(
            flex_grow: 1.0,
            display: Display::Flex,
            flex_direction: FlexDirection::Column,
            justify_content: JustifyContent::Center,
            align_items: AlignItems::Center,
            gap: px(12),
            background_color: Color::hex(0x0B0B0F),
        )) {
            Text(
                value: computed(move || format!("Count: {}", count.get())),
                style: css!(color: Color::hex(0xFFFFFF), font_size: px(28)),
            )
            View(
                style: css!(
                    padding: (px(10), px(20)),
                    border_radius: px(10),
                    background_color: Color::hex(0x7C5CFF),
                ),
                on_tap: move |_| count.set(count.get() + 1),
            ) {
                Text(value: "+1", style: css!(color: Color::hex(0xFFFFFF)))
            }
        }
    }
}

Whisker hot reload — edit the code, save, and the running app updates in under a second with state intact

Edit, save — the running app hot-reloads in under a second, with state intact.

Get started

cargo install whisker-cli
rustup target add aarch64-apple-ios-sim   # iOS Simulator on Apple silicon
whisker new my-app && cd my-app
whisker run ios          # also: android, web, macos

Each platform needs its Rust target: aarch64-linux-android for Android (plus the Android SDK, NDK, and a JDK), wasm32-unknown-unknown for Web, and x86_64-apple-ios instead for the iOS Simulator on an Intel Mac. Run whisker doctor to see what is missing, or follow Installation.

whisker run watches your source and hot-patches the running app in under a second, without a restart. Components you didn't edit keep their state.

App metadata and platform settings live in whisker.rs. whisker run and whisker build generate the native projects from it under gen/, so there is nothing else to run. Add plugins with cargo add and configure them there.

Documentation

Everything — installation, core concepts, guides, and the full API reference — lives at whisker.rs/docs.

Skills for AI coding agents

Install the Whisker skill for your coding agent (Claude Code, Codex, Cursor, Gemini CLI and others), so it follows Whisker's model instead of guessing from other frameworks:

npx skills add whiskerrs/whisker
Skill What it gives the agent
whisker Building, running and verifying Whisker apps: the reactivity rules, the dev loop, and where to read for each task

Status

Pre-alpha. The retained Rust runtime, typed styling, Host renderers, modules, routing, and hot reload work across iOS, Android, Web, and Desktop. APIs may still change before 1.0.

License

Licensed under either of Apache-2.0 or MIT at your option.

whisker (whiskerrs/whisker)

正在搜索数据库…

这是什么?一个用 Rust 编写的框架,用于构建原生 iOS、Android、Web 和桌面应用。它使用细粒度响应式运行时和原生 Host 渲染器,没有虚拟 DOM。
这是我要基于它编写代码的框架,还是现成的应用?是一个让你基于它编写代码的框架。你用 Rust 编写应用,然后运行 'whisker run' 或 'whisker build',它会为你在 gen/ 下生成原生项目。
我该怎么让它跑起来?为你需要的每个平台安装对应的 Rust 目标:Android 使用 aarch64-linux-android,Web 使用 wasm32-unknown-unknown,Intel Mac 上的 iOS 模拟器使用 x86_64-apple-ios。然后运行 'whisker doctor' 查看缺少什么。
我需要先安装什么?带有各平台对应目标的 Rust。开发 Android 还需要 Android SDK、NDK 和 JDK。'whisker doctor' 会告诉你缺少什么。
它能用于正式项目吗?还不行。它目前处于预亚发布阶段(pre-alpha):运行时、样式、渲染器、路由和热重载已在四个平台上可用,但在 1.0 版本之前,API 仍可能发生变化。
它使用虚拟 DOM 吗?不使用。它使用细粒度响应式运行时和原生 Host 渲染器,而不是虚拟 DOM。
它如何处理布局?布局由 Taffy 布局引擎完成,与响应式运行时和原生 Host 渲染器协同工作。
有哪些类似的项目?compose-multiplatform, Valdi, perry, native, gea, core, flet, Avalonia
作者
whiskerrs
大小
165.9 MB
星标
706
时长
6个月
提交 · 90 天