Skip to content

getRuntime

The getRuntime function returns the detected runtime environment: Browser, Node, Deno, Bun, or Unknown.

Syntax

typescript
getRuntime(): 'Browser' | 'Node' | 'Deno' | 'Bun' | 'Unknown';

Parameters

This function does not take any parameters.

Returns

TypeDescription
'Browser' | 'Node' | 'Deno' | 'Bun' | 'Unknown'The detected runtime environment

Examples

typescript
getRuntime();
// => "Browser", "Node", "Deno", "Bun" or "Unknown"

Notes

  • Uses helper functions to detect the environment.
  • Useful for adapting behavior according to the runtime.

References

Released under the MIT License.