Rhai is a Rust crate that embeds a small scripting language for safe application extension. It targets native and WebAssembly builds with optional sync support for multithreaded hosts.
Overview
Application authors embed Rhai when they want user-defined logic without shipping a separate interpreter process. The engine evaluates scripts through an AST walker tuned for reasonable throughput on typical automation tasks.
Rhai emphasizes sandboxed execution with limited unsafe code inside the engine itself, passes Miri validation, and can be compiled for no_std or WASM targets alongside mainstream desktop and server platforms supported by Rust.
Documentation in The Rhai Book explains syntax, API binding, and security considerations, while an online playground offers WASM-powered editing with direct evaluation.
Rust developers integrate Rhai for configuration DSLs, game mod scripting, workflow customization, and other cases where untrusted or power-user scripts must stay inside process guardrails.
Key features
- Embeddable Rust scripting engine
- AST-based evaluation
- WebAssembly target support
- Optional Send and Sync mode
- no_std build path
- Miri-tested safety focus
- Dual Apache and MIT license
- Online WASM playground
Use cases
- Rust app plugin scripting
- Rule and config DSLs
- Game logic customization
- WASM-hosted script trials
- Embedded automation hooks