Skip to main content

isWorkletRuntime
Available from 0.8.0

Checks if the current runtime is a Worklet Runtime, either the UI Runtime or a Worker Runtime.

Reference

import {
isWorkletRuntime,
scheduleOnUI,
scheduleOnRuntime,
createWorkletRuntime,
} from 'react-native-worklets';

console.log(isWorkletRuntime()); // false

scheduleOnUI(() => {
console.log(isWorkletRuntime()); // true
})();

const workerRuntime = createWorkletRuntime();
scheduleOnRuntime(workerRuntime, () => {
console.log(isWorkletRuntime()); // true
})();

Type definitions

function isWorkletRuntime(): boolean;

Returns

true if the current runtime is a Worklet Runtime, false otherwise.

Remarks

  • The function checks the value of globalThis.__RUNTIME_KIND to determine the kind of the current runtime. See getRuntimeKind for more details.

We are Software Mansion.