neon
Rust bindings for writing safe and fast native Node.js modules.
A tool for writing Node.js add-ons in Rust, compile Rust functions and call them from JavaScript as if they were ordinary JS functions, starting with a single npm command.
Neon is a tool for writing Node.js add-ons in Rust. Node.js normally runs JavaScript, but sometimes developers need faster, lower-level code running alongside it. Add-ons allow that, and Neon makes it possible to write those add-ons in Rust rather than in C or C++.
Rust is a programming language known for memory safety and performance. Neon bridges Rust and Node.js so a developer can write Rust functions, compile them, and call them from JavaScript as if they were ordinary JavaScript functions. Getting started takes a single npm command that creates a new project ready to build.
The project runs on Linux, macOS, and Windows. It supports all current and maintained releases of Node.js, and has experimental support for Bun, an alternative JavaScript runtime. On the Rust side, it requires stable Rust version 1.65 or higher, and the project is tested against the latest stable, beta, and nightly Rust releases.
The README includes a short code sample showing a Rust function that builds a JavaScript array containing a number, a string, and a boolean, then returns it to the caller. This shows how Rust code interacts with JavaScript values through Neon's API. Full documentation lives on the project website, and more examples are available in a separate examples repository.
Version 1.0.0 introduced several breaking changes to fix correctness issues and improve consistency. A migration guide is available for developers moving existing projects to the new version. The community communicates through a Slack workspace open to anyone. Testing the project uses both npm and Cargo workspace commands. It is licensed under either Apache 2.0 or MIT, at the user's choice.
Where it fits
- Build a fast number-crunching module in Rust and call it from a Node.js web server to speed up slow JavaScript code.
- Write a CPU-intensive image or data processing function in Rust as a drop-in replacement for a slow JavaScript implementation.
- Create a performance-critical Node.js npm package by writing the core logic in Rust using Neon's safe API.