0.0.38 • Published 9 months ago

userust v0.0.38

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

useRust

Add custom Rust WebAssembly hooks to React and SolidJS projects

// my-rust-code/src/lib.rs
#[wasm_bindgen]
pub fn add(a: i32, b: i32) -> i32 {
    a + b
}
import useRust from 'my-rust-code'

const Calculator = () => {
  const { rust, error } = useRust()
  return <div>1+1={rust?.add(1,1)}</div>
}

How it works

  1. Have an existing React or SolidJS project
  2. npx userust init NAME will compile and install a custom useRust hook to your project
  3. Use it in your project: import useRust from 'NAME'
  4. Make changes to ./NAME/src/lib.rs
  5. npm run NAME:build will recompile the useRust hook

Alternatively you can use npm run NAME:watch to automatically recompile after changes to Rust code

Uses wasm-bindgen. See Rust code examples at its documentation page.

Features

  • Leverage Rust and Wasm to speed up critical parts of your frontend
  • Fully typed TypeScript interface, works in JavaScript projects as well
  • No limitations for Rust code, provides a minimal, properly configured boilerplate to start with
  • Develop frontend and Rust code from the same monorepo with a few simple commands
  • Tested on Linux, MacOS and Windows
  • npm, pnpm and yarn supported
  • Simple interface inspired by SWR library

Full documentation

Licence

The MIT License.

0.0.38

9 months ago

0.0.20

1 year ago

0.0.21

1 year ago

0.0.22

1 year ago

0.0.23

1 year ago

0.0.24

1 year ago

0.0.25

1 year ago

0.0.37

1 year ago

0.0.15

1 year ago

0.0.16

1 year ago

0.0.17

1 year ago

0.0.18

1 year ago

0.0.19

1 year ago

0.0.30

1 year ago

0.0.31

1 year ago

0.0.32

1 year ago

0.0.10

1 year ago

0.0.33

1 year ago

0.0.11

1 year ago

0.0.34

1 year ago

0.0.12

1 year ago

0.0.35

1 year ago

0.0.13

1 year ago

0.0.36

1 year ago

0.0.14

1 year ago

0.0.2

1 year ago

0.0.26

1 year ago

0.0.9

1 year ago

0.0.27

1 year ago

0.0.28

1 year ago

0.0.29

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.1

1 year ago