Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/margelo/react-native-worklets-core

๐Ÿงต A library to run JS functions ("Worklets") on separate Threads
https://github.com/margelo/react-native-worklets-core

async background hacktoberfest multithreading native react threads worklet worklets

Last synced: 4 days ago
JSON representation

๐Ÿงต A library to run JS functions ("Worklets") on separate Threads

Awesome Lists containing this project

README

        



# ๐Ÿงต react-native-worklets-core

A [Worklet](docs/WORKLETS.md) runner for React Native.

```js
const worklet = () => {
'worklet'
return Math.random()
}
```

> [!NOTE]
> In most cases, react-native-worklets-core shouldn't be used as a standalone dependency but rather as a peer-dependency for other modules such as [react-native-vision-camera](https://github.com/mrousavy/react-native-vision-camera), [react-native-wishlist](https://github.com/margelo/react-native-wishlist), or [react-native-skia](https://github.com/Shopify/react-native-skia).

## Installation

1. Install the library from npm:
```sh
yarn add react-native-worklets-core
```
2. Add the babel plugin to your `babel.config.js`:
```js
module.exports = {
plugins: [
["react-native-worklets-core/plugin"],
// ...
],
// ...
};
```
3. Restart Metro with clean cache:
```sh
yarn start --reset-cache
```

## Usage

See [USAGE.md](docs/USAGE.md)

## Contributing

See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.

## License

MIT

## Credits

* Credits go to [Christian Falch](https://github.com/chrfalch) for building the initial version of this library. You're amazing! ๐Ÿคฉ
* Credits go to [Software Mansion](https://swmansion.com) for introducing the concept of [Worklets](https://docs.swmansion.com/react-native-reanimated/docs/2.x/fundamentals/worklets/) in [Reanimated v2](https://github.com/software-mansion/react-native-reanimated). This library is inspired by Reanimated v2 with a few structural changes to the Worklets architecture to make it more flexible for different use-cases, such as integrating it with other C++ libraries like VisionCamera and WishList.