runOnUISync
runOnUISync lets you run a workletized function synchronously on the UI Runtime.
To compare it with scheduleOnUI and runOnUIAsync, see Running worklet functions on the UI runtime.
Reference
Code
Code
Colours connect each executing thread to its current code line. Recently executed lines fade over the next three ticks.
function myFunction(num) {
'worklet';
return num + 1;
}
const result = runOnUISync(myFunction, 0);
console.log(result); // 1
Console 0
No output yet
Output appears here as the code runs.


Type definitions
function runOnUISync<Args extends unknown[], ReturnValue>(
worklet: (...args: Args) => ReturnValue,
...args: Args
): ReturnValue;
Arguments
worklet
A function you want to execute on the UI Runtime.
args
Arguments to pass to the function.
Returns
runOnUISync returns the return value of the function passed as the first argument. It can only return values that can be converted to a Serializable.
Remarks
- The callback passed as the argument is automatically workletized and ready to be run on the UI Runtime.
Call table
| Mode | RN Runtime | UI Runtime | Worker Runtime |
|---|---|---|---|
| Bundle Mode | ✅ | ✅ | ✅ |
| Legacy Eval Mode | ✅ | ❌ | ❌ |
Platform compatibility
| Native | Web |
|---|---|
| ✅ | ❌ |