Husk Logo

Husk

A Rust-inspired language for building type-safe JavaScript.

Pattern matching, algebraic data types, and strong static typing — compiling to clean, readable JS that runs everywhere.

$ cargo install husk-lang

Why Husk?

The power of Rust's type system, the reach of JavaScript's ecosystem. Write once, run anywhere — with confidence.

Rust-like Syntax

Familiar syntax with pattern matching, algebraic data types, and powerful type inference. If you know Rust, you'll feel right at home.

Type Safety

Catch errors at compile time with a robust type system. Strong static typing with inference means safety without verbosity.

Developer Experience

Fast compile times, clear error messages, and excellent tooling. LSP support, code formatting, and editor integrations included.

JavaScript Interop

Seamlessly call npm packages and JavaScript libraries. Compiles to clean ES modules that integrate with any JS project.

Full LSP Support
VS Code & Neovim
Source Maps
Watch Mode

See it in action

Clean, expressive syntax that compiles to readable JavaScript. No runtime overhead, no magic — just better code.

Exhaustive pattern matching with algebraic data types

pattern-matching.hk
fn divide(a: i32, b: i32) -> Result<i32, String> {
    if b == 0 {
        Err("Division by zero")
    } else {
        Ok(a / b)
    }
}

fn main() {
    match divide(10, 2) {
        Ok(value) => println("Result: {}", value),
        Err(err) => println("Error: {}", err),
    }
    // Compiler ensures all cases are handled!
}
Compiles to clean ES modules or CommonJS