| Crates.io | streamlit |
| lib.rs | streamlit |
| version | 0.1.2 |
| created_at | 2025-12-19 15:21:23.932159+00 |
| updated_at | 2026-01-06 05:28:08.783953+00 |
| description | Streamlit - A faster way to build and share data apps. |
| homepage | |
| repository | https://github.com/killf/streamlit-rust |
| max_upload_size | |
| id | 1994995 |
| size | 456,756 |
A pure Rust implementation of Streamlit backend with WebSocket support, compatible with the official Streamlit frontend.
st.write(), st.button(), etc.)This is a Cargo workspace with the following members:
streamlit-rust/
├── streamlit/ # Main library crate
│ ├── src/
│ │ ├── api.rs # Streamlit API implementation
│ │ ├── server.rs # HTTP and WebSocket server
│ │ ├── elements/ # UI element implementations
│ │ ├── websocket/ # WebSocket handlers
│ │ ├── error.rs # Error types
│ │ └── lib.rs # Public API
│ └── examples/ # Example applications
└── streamlit-macros/ # Procedural macros (#[main])
The easiest way to try out streamlit-rust is to run the included examples:
# Run the basic example
cargo run --example basic
# Run the hello world example
cargo run --example hello
# Run the timer example
cargo run --example timer
# Run the container/columns example
cargo run --example container
The server will start on http://localhost:8501 by default.
use streamlit::*;
#[main]
async fn main(st: &Streamlit) {
// Set page title
st.title("Hello from Rust!");
// Write some text
st.write("This is a demonstration of Streamlit in Rust.");
// Display code
st.code("fn main() { println!(\"Hello, world!\"); }", "rust");
// Add a button
if st.button("Click me!") {
st.write("Button was clicked!");
}
}
ws://localhost:8501/_stcore/stream - Main WebSocket connectionGET /_stcore/health - Server statusPOST /api/run - Execute Rust codeGET / - Basic info pagest.write(content) - Plain text (supports markdown)st.title(content) / st.h1(content) - Title (h1)st.header(content) / st.h2(content) - Header (h2)st.sub_header(content) / st.h3(content) - Sub-header (h3)st.markdown(content) - Markdown content with extended optionsst.caption(content) - Small caption textst.badge(label) - Badge/icon componentst.code(code, language) - Syntax-highlighted code blockCodeOptions::new(code, language) - Advanced code display options
.line_numbers(bool) - Show line numbers.wrap_lines(bool) - Wrap long lines.height(...) - Set height.width(...) - Set widthst.container() - Container for grouping elementsst.container_options(...) - Container with options
.border(bool) - Show border.horizontal(bool) - Horizontal layout.gap(...) - Set gap size.alignment(...) - Set alignmentst.columns(n) - Create N columnsst.columns([v1, v2, ...]) - Create columns with custom weightsColumnsOptions::new(...) - Advanced column optionsst.button(label) - Button (returns true if clicked)st.button_options(...) - Button with options
.key(...) - Unique key.help(...) - Help tooltip.type(...) - Button type (primary/secondary).icon(...) - Icon.disabled(bool) - Disable button.shortcut(...) - Keyboard shortcutst.divider() - Horizontal dividerst.divider_options(...) - Custom divider width┌─────────────────┐ ┌─────────────────┐
│ Streamlit │ │ Streamlit │
│ Frontend │◄──►│ Rust Backend │
│ (JavaScript) │ │ (WebSocket) │
└─────────────────┘ └─────────────────┘
# Build the workspace
cargo build
# Build with optimizations
cargo build --release
cargo test
cargo fmt
use streamlit::*;
#[main]
async fn main(st: &Streamlit) {
st.write("Hello world!");
}
use streamlit::*;
#[main]
async fn main(st: &Streamlit) {
st.title("🚀 Streamlit Rust Examples");
st.header("Welcome to Streamlit in Rust!");
st.sub_header("This is a sub-header");
st.markdown(
"You can use **bold text**, *italic text*, and `inline code` in markdown.\n\n\
- Bullet point 1\n\
- Bullet point 2\n\
- Bullet point 3",
);
}
use streamlit::*;
#[main]
async fn main(st: &Streamlit) {
st.header("Code Examples");
st.sub_header("Rust Code");
st.code(
"fn main() {
println!(\"Hello, Streamlit!\");
}",
"rust",
);
st.sub_header("Python Code with line numbers");
st.code_options(
CodeOptions::new(
"import streamlit as st\n\nst.write(\"Hello from Python!\")",
"python",
)
.line_numbers(true),
);
}
use streamlit::*;
#[main]
async fn main(st: &Streamlit) {
st.title("Container and Columns");
st.write("Content outside container");
// Container with border
let container = st.container_options(ContainerOptions::new().border(true));
container.write("Inside container");
container.write("Also inside container");
st.write("Back to main content");
// Create columns
if let [col1, col2, col3] = st.columns([1, 2, 1]) {
col1.write("Left column (narrow)");
col2.write("Middle column (wide)");
col3.write("Right column (narrow)");
}
}
use streamlit::*;
#[main]
async fn main(st: &Streamlit) {
st.title("Button Examples");
// Simple button
if st.button("Click me!") {
st.write("Button was clicked!");
}
// Button with options
if st.button_options(
ButtonOptions::new("Primary Action")
.icon("🚀")
.help("This is a helpful tooltip"),
) {
st.write("Primary action triggered!");
}
// Multiple buttons in columns
if let [col1, col2, col3] = st.columns(3) {
if col1.button("Button 1") {
col1.write("Clicked 1");
}
if col2.button("Button 2") {
col2.write("Clicked 2");
}
if col3.button("Button 3") {
col3.write("Clicked 3");
}
}
}
use streamlit::*;
#[main]
async fn main(st: &Streamlit) {
st.title("Badges and Captions");
st.badge(BadgeOptions::new("Home").color("red").icon("🏠"));
st.badge(BadgeOptions::new("Active").color("green").icon("✅"));
st.badge(BadgeOptions::new("Warning").color("orange").icon("⚠️"));
st.write("Some content here");
st.caption("This is a small caption text below the content");
}
This implementation is designed to be compatible with:
git checkout -b feature/amazing-feature)cargo test)Apache License 2.0 - see LICENSE file for details.