Skip to main content

Getting started

What is React Native Worklets?

React Native Worklets is a library that allows you to run JavaScript code in parallel on multiple threads and runtimes.

While the library is in transitional period where we hone the API, all its features are functionally stable and ready to use in production.

Prerequisites

info

Worklets library isn't tested on the Legacy Architecture (Paper). We highly recommend migrating to the New Architecture (Fabric) prior to using Worklets.

Installation

Step 1: Install the package

Install react-native-worklets package from npm:

npm install react-native-worklets

Step 2: Rebuild native dependencies

Run prebuild to update the native code in the ios and android directories.

npx expo prebuild

And that's it! Worklets is now configured in your Expo project.

React Native Community CLI

When using React Native Community CLI, you also need to manually add the react-native-worklets/plugin plugin to your babel.config.js.

  module.exports = {
presets: [
... // don't add it here :)
],
plugins: [
...
'react-native-worklets/plugin',
],
};

Why do I need this?

In short, the Worklets babel plugin automatically converts special JavaScript functions (called worklets) to allow them to be passed and run on the Worklet Runtimes

Since Expo SDK 54, the Expo starter template includes the Worklets babel plugin by default.

To learn more about the plugin head onto to Worklets babel plugin section.

npm start -- --reset-cache

Android

No additional steps are necessary.

iOS

While developing for iOS, make sure to install pods first before running the app:

cd ios && pod install && cd ..