npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

rust-bindings

v0.0.9

Published

Automates the process of building a native Node module in Rust.

Downloads

12

Readme

Rust Bindings

An npm package that automates the process of building native Node modules in Rust.

Example

See the nanny-demo repository for a simple but complete example of a native Rust module built with rust-bindings.

Usage

Project Structure

Set up your project as both a node package and a Rust project. Rust source files go in src as usual and Node source files go wherever you like, such as the root directory or the lib directory:

├── package.json
├── Cargo.toml
├── src/
└── lib/

package.json

You should have rust-bindings in your dependencies, and a postinstall script set to run rust-bindings build. This will ensure that the necessary project boilerplate (the binding.gyp build manifest and top-level C++ addon file) are generated before publishing.

  ...
  "dependencies": {
    "rust-bindings": "0.0.6"
  },
  "scripts": {
    "postinstall": "rust-bindings build"
  }
  ...

If you want a debug build, change the postinstall command to "rust-bindings build --debug".

Building

Build your native module simply by running npm install from the project directory.

Clients who depend on your native module, directly or indirectly, don't have to do anything special. (However, they do have to have the required build tools installed on their machine. Hopefully we can improve this situation in the future.)

Requiring

You can easily require your native module from JS without having to specify the build directory; rust-bindings figures this out for you:

var my_native_module = require('rust-bindings')();

You can override defaults by passing an optional options object to the rust-bindings module:

| Option | Description | Type | Default | | --------- | ------------- | -------- | ------------------------------------------------------------------------ | | root | project root | string | nearest containing directory of caller with package.json or node_modules | | name | library name | string | parse($manifest).package.name | | manifest | manifest path | path | $root/Cargo.toml |

Setup

Note: this is currently only working on OS X.

OS X

  • XCode
  • Node: io.js v3 or later. I recommend using nvm:
% nvm install iojs

Right now multirust is a mandatory dependency because it's used to run on Rust nightly by default. Once the fix for a jemalloc linking bug makes it through the trains to stable, multirust will be an optional dependency and rust-bindings will default to the system Rust compiler.

Known Limitations

  • I've only gotten this working on OS X with io.js >= 3.
  • It would be ideal to make Rust available as npm packages, to avoid clients of a native module having to install Rust on their system.
  • There's no way to fallback on precompiled or portable implementations.

I would love to work with people on fixing these limitations!

License

MIT