getCurrentThreadId
Available from 0.13.0
getCurrentThreadId returns the id of the thread which currently executes JavaScript on the calling Runtime. The returned id is a stringified result of std::this_thread::get_id().
Reference
import { getCurrentThreadId, runOnUISync, scheduleOnUI } from 'react-native-worklets';
console.log(getCurrentThreadId()); // The JS thread id.
scheduleOnUI(() => {
'worklet';
console.log(getCurrentThreadId()); // The UI thread id.
});
runOnUISync(() => {
'worklet';
console.log(getCurrentThreadId()); // The JS thread id.
})


Type definitions
function getCurrentThreadId(): string;
Returns
getCurrentThreadId returns a string with the id of the current thread. The format of the id is platform-specific.
Call table
| Mode | RN Runtime | UI Runtime | Worker Runtime |
|---|---|---|---|
| Bundle Mode | ✅ | ✅ | ✅ |
| Legacy Eval Mode | ✅ | ✅ | ✅ |
Platform compatibility
| Native | Web |
|---|---|
| ✅ | ❌ |