# Ratzilla
**Repository Path**: mirrors/Ratzilla
## Basic Information
- **Project Name**: Ratzilla
- **Description**: Ratzilla 是基于 Ratatui 构建用于创造 Terminal 风格的 Web 应用的框架
- **Primary Language**: Rust
- **License**: MIT
- **Default Branch**: main
- **Homepage**: https://www.oschina.net/p/ratzilla
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2025-04-25
- **Last Updated**: 2025-10-18
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
[](https://github.com/orhun/ratzilla)
[](https://crates.io/crates/ratzilla)
[](https://docs.rs/ratzilla)
**Watch the conference talk:** [Bringing Terminal Aesthetics to the Web With Rust (and Vice Versa)](https://www.youtube.com/watch?v=iepbyYrF_YQ)
# Ratzilla
Build terminal-themed web applications with Rust and WebAssembly. Powered by [Ratatui].
## Quickstart
### Templates
Install [`cargo-generate`](https://github.com/cargo-generate/cargo-generate):
```shell
cargo install cargo-generate
```
Generate a new project:
```shell
cargo generate orhun/ratzilla
```
And then [serve the application on your browser](#serve) ➡️
See [templates](./templates) for more information.
### Manual Setup
Add **Ratzilla** as a dependency in your `Cargo.toml`:
```sh
cargo add ratzilla
```
Here is a minimal example:
```rust no_run
use std::{cell::RefCell, io, rc::Rc};
use ratzilla::ratatui::{
layout::Alignment,
style::Color,
widgets::{Block, Paragraph},
Terminal,
};
use ratzilla::{event::KeyCode, DomBackend, WebRenderer};
fn main() -> io::Result<()> {
let counter = Rc::new(RefCell::new(0));
let backend = DomBackend::new()?;
let terminal = Terminal::new(backend)?;
terminal.on_key_event({
let counter_cloned = counter.clone();
move |key_event| {
if key_event.code == KeyCode::Char(' ') {
let mut counter = counter_cloned.borrow_mut();
*counter += 1;
}
}
});
terminal.draw_web(move |f| {
let counter = counter.borrow();
f.render_widget(
Paragraph::new(format!("Count: {counter}"))
.alignment(Alignment::Center)
.block(
Block::bordered()
.title("Ratzilla")
.title_alignment(Alignment::Center)
.border_style(Color::Yellow),
),
f.area(),
);
});
Ok(())
}
```
Add your `index.html`. During build, `trunk` will automatically inject and initialize your Rust code (compiled to
WebAssembly) as a JavaScript module.
index.html
```html
Ratzilla
```
And then [serve the application on your browser](#serve) ➡️
## Serve
Install [trunk] to build and serve the web application.
```sh
cargo install --locked trunk
```
Add compilation target `wasm32-unknown-unknown`:
```sh
rustup target add wasm32-unknown-unknown
```
Then serve it on your browser:
```sh
trunk serve
```
Now go to [http://localhost:8080](http://localhost:8080) and enjoy TUIs in your browser!
## Deploy
To build the WASM bundle, you can run the following command:
```sh
trunk build --release
```
Then you can serve the server from the `dist` directory.
Example Build Script
```bash
#!/bin/bash
set -euo pipefail
export HOME=/root
# Install Rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y -t wasm32-unknown-unknown --profile minimal
source "$HOME/.cargo/env"
# Install trunk using binstall
curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
cargo binstall --targets x86_64-unknown-linux-musl -y trunk
# Build project with trunk
trunk build --release
```
### Vercel
There is a Vercel deployment template available for Ratzilla [here](https://vercel.com/templates/other/ratzilla).
## Documentation
- [API Documentation](https://docs.rs/ratzilla)
- [Backends](https://docs.rs/ratzilla/latest/ratzilla/backend/index.html)
- [Widgets](https://docs.rs/ratzilla/latest/ratzilla/widgets/index.html)
## Examples
- [Minimal](https://github.com/orhun/ratzilla/tree/main/examples/minimal) ([Preview](https://orhun.dev/ratzilla/minimal))
- [Demo](https://github.com/orhun/ratzilla/tree/main/examples/demo) ([Preview](https://orhun.dev/ratzilla/demo))
- [Pong](https://github.com/orhun/ratzilla/tree/main/examples/pong) ([Preview](https://orhun.dev/ratzilla/pong))
- [Colors RGB](https://github.com/orhun/ratzilla/tree/main/examples/colors_rgb) ([Preview](https://orhun.dev/ratzilla/colors_rgb))
- [Animations](https://github.com/orhun/ratzilla/tree/main/examples/animations) ([Preview](https://orhun.dev/ratzilla/animations))
- [World Map](https://github.com/orhun/ratzilla/tree/main/examples/world_map) ([Preview](https://orhun.dev/ratzilla/world_map))
## Websites built with Ratzilla
- - The official website of Ratzilla
- - Terminal Collective community website
- - Resistor calculator
- - Personal website of Tim Beck
- - Conway's Game of Life
- - Map of apt-swarm p2p locations
- [TachyonFX FTL](https://junkdog.github.io/tachyonfx-ftl/) - DSL editor and previewer for TachyonFX effects
- - Personal website of Emrecan Şuşter ([source](https://github.com/Tarbetu/website))
- - A tachyonfx tech demo: animated KDE keyboard shortcut viewer
- - Personal website of 0x01d ([source](https://github.com/0x01d/website))
- - Glues, a Vim-inspired TUI note-taking app ([source](https://github.com/gluesql/glues))
## Acknowledgements
Thanks to [Webatui] projects for the inspiration.
Special thanks to:
- [Martin Blasko] for his huge help with the initial implementation.
- [Adrian Papari] for implementing WebGL2 backend.
Lastly, thanks to [Ratatui] for providing the core UI components.
[trunk]: https://trunkrs.dev
[Ratatui]: https://ratatui.rs
[`DomBackend`]: https://docs.rs/ratzilla/latest/ratzilla/struct.DomBackend.html
[`CanvasBackend`]: https://docs.rs/ratzilla/latest/ratzilla/struct.CanvasBackend.html
[`Hyperlink`]: https://docs.rs/ratzilla/latest/ratzilla/widgets/struct.Hyperlink.html
[Webatui]: https://github.com/TylerBloom/webatui
[Martin Blasko]: https://github.com/MartinBspheroid
[Adrian Papari]: https://github.com/junkdog
[Vercel]: https://vercel
## Contributing
Pull requests are welcome!
Consider submitting your ideas via [issues](https://github.com/orhun/ratzilla/issues/new) first and check out the [existing issues](https://github.com/orhun/ratzilla/issues).
## License
[](./LICENSE-MIT)
[](./LICENSE-APACHE)
Licensed under either of [Apache License Version 2.0](./LICENSE-APACHE) or [The MIT License](./LICENSE-MIT) at your option.
🦀 ノ( º \_ º ノ) - respect crables!
## Copyright
Copyright © 2025, [Orhun Parmaksız](mailto:orhunparmaksiz@gmail.com)