Skip to content

Latest commit

 

History

History
50 lines (32 loc) · 786 Bytes

readme.md

File metadata and controls

50 lines (32 loc) · 786 Bytes

Rust-NodeJS Integration Example

This repository demonstrates how to integrate Rust and Node.js using WebAssembly.

Structure

  • rust/: Contains the Rust code.
  • node/: Contains the Node.js code that uses the WebAssembly module generated from the Rust code.

Setup

Rust

  1. Navigate to the rust directory:

    cd rust 
  2. Build the Rust project using wasm-pack:

    wasm-pack build --target nodejs 
  3. Copy the pkg directory to the node directory.

    cp -r pkg ../node/

Node

  1. Navigate to the node directory:

    cd ../node 
  2. Build the Rust project using wasm-pack:

    npm install 
  3. Run the Node.js script:

    ts-node ./index.ts