BridgeRust
Write Rust once, deploy to Python and Node.js.
BridgeRust is a unified framework for building cross-language Rust libraries. It eliminates the complexity of managing separate bindings for PyO3 (Python) and napi-rs (Node.js) by providing a single, unified macro system.
Website: bridgerust.dev
🚀 Features
- Unified Logic: One
#[bridgerust::export]macro handles both Python and Node.js generation. - Zero Config: No need to manually configure PyO3 or napi-rs builds.
- Type Safety: Automatic type mapping between Rust, Python, and TypeScript.
🎯 Best Use Cases
BridgeRust is currently SDK-Ready and ideal for:
- Unified SDKs / Clients: Perfect for database drivers (like Embex) or API clients. Seamlessly handles
async/awaitand complex JSON objects. - CPU-Intensive Data Processing: Expose high-performance Rust logic (parsers, encryption, image processing) to interpreted languages with minimal overhead.
- Shared Logic Cores: Write business validation rules once in Rust structs/enums and reuse them across your Node.js backend and Python data pipelines.
📦 Usage
Add to your Cargo.toml:
[]
= "0.1"
Annotate your Rust functions:
use export;
🏗️ Building
BridgeRust creates standard Python wheels and Node.js native modules.
Using the CLI (Recommended)
# Install the CLI
# Initialize a new project
# Development (Live Reload)
# Build for all targets
# Run tests
# Run benchmarks
# Publish packages
Manual Building
# Build for Python
# Build for Node.js
📚 Documentation
- Quick Reference - Cheat sheet for common patterns
- Getting Started Guide - Complete tutorial
- Migration Guide - Migrate from PyO3/napi-rs
- Examples - Code examples and patterns
- Troubleshooting - Common issues and solutions
- CLI Documentation - CLI tool reference
- E2E Test Examples - Integration test examples
🎯 Quick Example
use export;
Build and use from both Python and Node.js with a single command!