Quick Start
import { Tabs, TabItem } from ‘@astrojs/starlight/components’;
Quick Start Guide
Section titled “Quick Start Guide”BridgeRust makes it easy to write high-performance Rust libraries for Python and Node.js.
Prerequisites
Section titled “Prerequisites”- Rust: Install from rustup.rs
- Python: 3.7+ (for Python bindings)
- Node.js: 14+ (for Node.js bindings)
Step 1: Install the CLI
Section titled “Step 1: Install the CLI”The bridge CLI is your main tool for creating and managing BridgeRust projects.
cargo install bridgebridge --versionStep 2: Create a Project
Section titled “Step 2: Create a Project”Generate a new project with the default template.
bridge new my-librarycd my-libraryThis creates a project structure ready for both Python and Node.js.
Step 3: Write Rust Code
Section titled “Step 3: Write Rust Code”Open src/lib.rs and define your exposed API using the #[bridge] macro.
use bridgerust::prelude::*;
#[bridge]pub fn add(a: i32, b: i32) -> i32 { a + b}Step 4: Develop & Build
Section titled “Step 4: Develop & Build”Use the live development server to watch for changes and rebuild automatically.
bridge devTo build release artifacts:
bridge build --allStep 5: Verified Speed!
Section titled “Step 5: Verified Speed!”You now have a native Python wheel in dist/*.whl and a Node.js package in dist/*.tgz.
python
python -c "import my_library; print(my_library.add(1, 2))"