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
Code
Code
Colours connect each executing thread to its current code line. Recently executed lines fade over the next three ticks.
function logThread() {
'worklet';
console.log(getCurrentThreadId());
}
logThread(); // The JS thread id.
scheduleOnUI(logThread); // The UI thread id.
runOnUISync(logThread); // The JS thread id.
Console 0
No output yet
Output appears here as the code runs.


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 |
|---|---|
| ✅ | ❌ |