Socket
Book a DemoInstallSign in
Socket

detect-runtime

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

detect-runtime

Detects the current runtime environment (Node.js, Cloudflare Workers, Deno, ...)

1.0.4
latest
Source
npmnpm
Version published
Weekly downloads
619
138.08%
Maintainers
1
Weekly downloads
 
Created
Source

detect-runtime

Small library to detect the current JavaScript runtime. The list of supported runtimes is based on the WinterCG Runtime Keys proposal:

  • edge-routine Alibaba Cloud Edge Routine
  • workerd Cloudflare Workers
  • deno Deno and Deno Deploy
  • lagon Lagon
  • react-native React Native
  • netlify Netlify Edge Functions
  • electron Electron
  • node Node.js
  • bun Bun
  • edge-light Vercel Edge Functions
  • fastly Fastly Compute@Edge

This package is properly typed and exported to both ESM and CJS.

Installation

detect-runtime is published on NPM:

# NPM
npm install detect-runtime
# Yarn
yarn add detect-runtime
# PNPM
pnpm install detect-runtime
# Bun
bun install detect-runtime

Or in Deno:

import { ... } from 'npm:detect-runtime'

Usage

Import and call the detectRuntime() function from the detect-runtime package:

import { detectRuntime } from 'detect-runtime'

const runtime = detectRuntime()
//    ^? 'edge-routine' | 'workerd' | 'deno' | 'lagon' | 'react-native' | 'netlify | 'electron | 'node | 'bun | 'edge-light | 'unknown'

You can also import the Runtime type which is the return type of detectRuntime().

License

MIT

Keywords

runtime

FAQs

Package last updated on 15 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.