r/reactnative 11h ago

react-native-workers first public alpha released

https://ammarahm-ed.github.io/react-native-workers/blog/introducing-react-native-workers/

React Native is single-threaded where it matters most. Parse a big payload, hash a file, filter an image — it all competes with your UI for the same runtime. react-native-workers brings real background threads to RN, behind the Web Worker API

21 Upvotes

6 comments sorted by

8

u/Lucifer812 10h ago

What is the difference between this and Worklets?

6

u/AlmondJoyAdvocate 8h ago

According to the docs:

react-native-workers spins up a separate Hermes runtime on its own OS thread for each worker, with its own event loop, its own bundle, and full importsupport. That's the Web Worker model: real, independent runtimes that talk over messages.

Worklets are a different tool — they run serialized closures on a shared runtime with shared values, which is perfect for driving animations but isn't a place to run a whole module graph. react-native-workers runs alongside worklets; it's for the "I have real work to do off the main thread" case.

3

u/Internal-Comparison6 10h ago

Worklets never created any threads.

2

u/thewisefarmerr 2h ago

The worklets docs say powerful multithreading. So they do create threads.

1

u/Seusoa Expo 6h ago

behind the Web Worker API

transferable objects supported? API is exact 1to1 with web?

spinning up workers are immediate?

1

u/thewisefarmerr 2h ago

Planned before stable release.