Write high-performance infrastructure libraries for Python, Node.js, and other ecosystems, powered by a shared Rust core.
As developers, we often face a difficult choice when building libraries: write in a high-level language for ease of use (but sacrifice performance), or write in a low-level language like C++/Rust and deal with the nightmare of maintaining bindings for multiple languages.
If you choose the latter, you likely juggle pyo3 for Python and napi-rs for Node.js. You end up with snippets of glue code scattered everywhere, inconsistent APIs across languages, and a complex build pipeline that breaks if you look at it wrong.
BridgeRust changes that.
What is BridgeRust?
BridgeRust is a unified framework that lets you write your library once in Rust and automatically deploy native, high-performance bindings to both Python and Node.js (with more languages coming).
It's not just a binding generator; it's a complete toolkit that handles:
Project Scaffold: Set up a multi-language project in seconds.
Unified Macro System: One#[export]macro for all languages.
Type Conversions: Automatic mapping ofVec,Option,Result, and more.
Building & Publishing: Integrated CLI to build wheels and npm packages.
The "Write Once" Magic
Let's look at how easy it is to expose Rust code to the world.
1. Initialize
bridge init my-awesome-lib
cd my-awesome-lib
2. Write Rust
In src/lib.rs, you simply tag your functions and structs with #[export].
use bridgerust::export;
#[export]
pub fn greet(name: String) -> String {
format!("Hello, {}! This is logic from Rust.", name)
}
#[export]
pub struct Point {
pub x: f64,
pub y: f64,
}
#[export]
pub fn fast_math(points: Vec<Point>) -> f64 {
// Heavy computation here...
points.iter().map(|p| p.x + p.y).sum()
}
3. Build
bridge build --all
That's it. BridgeRust generates:
- A Python wheel (
pip install ...) - A Node.js native addon (
npm install ...)
Consuming the Library
The generated bindings feel native in every language.
Python:
import my_awesome_lib
print(my_awesome_lib.greet("Pythoneer"))
p1 = my_awesome_lib.Point(1.0, 2.0)
result = my_awesome_lib.fast_math([p1])
Node.js:
const lib = require("my-awesome-lib");
console.log(lib.greet("JavaScripter"));
const p1 = new lib.Point(1.0, 2.0);
const result = lib.fastMath([p1]);
Notice how fast_math became fastMath automatically in JS? BridgeRust handles idiomatic naming conventions for you.
Real-World Example: Embex
We built Embex, a universal vector database client, using BridgeRust. It connects to Pinecone, Qdrant, LanceDB, and more.
By using BridgeRust, we maintained a single codebase for the core logic (connection pooling, retry strategies, SIMD operations) while offering native packages for both Python (pip install embex) and Node.js (npm install @bridgerust/embex).
Why Choose BridgeRust?
Zero Boilerplate: No more manualPyModuleornapi_register_moduledefinitions.
Performance: Zero-cost abstractions where possible. Your code runs at Rust speeds.
Developer Experience: ThebridgeCLI simplifies the entire lifecycle from init to publish.
Consistency: Ensure your Python and JS users get exactly the same features and bug fixes at the same time.
Get Started
BridgeRust is open source and ready for you to try.
- Install the CLI:
cargo install bridge
- Check out the logic: github.com/bridgerust/bridgerust
- Read the docs: bridgerust.dev
Stop writing glue code. Start building bridges. 🦀🌉