is-lambda is a lightweight utility package designed to detect whether the current JavaScript execution environment is an AWS Lambda server. It achieves this by inspecting well-known AWS Lambda-specific environment variables such as `AWS_LAMBDA_FUNCTION_NAME`, `AWS_REGION`, and `LAMBDA_TASK_ROOT`. The current stable version is 1.0.1. Due to its focused and simple nature, its release cadence is typically very slow, with updates primarily occurring if AWS Lambda's environment signature changes or critical bug fixes are required. Its key differentiator is its minimalism, providing a single boolean value without additional overhead or complex configuration, making it suitable for quick environmental checks in serverless applications or conditional logic based on the deployment environment.
npm install is-lambdaVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `is-lambda` to check the execution environment and shows conditional logic for both Lambda and non-Lambda contexts, including accessing common AWS environment variables.
Ensure your `is-lambda` version is up-to-date if AWS makes significant changes to its environment variable landscape. Periodically test your application in new Lambda runtimes.
Manually set the necessary AWS Lambda environment variables in your local development environment or test runner (`AWS_LAMBDA_FUNCTION_NAME`, `AWS_REGION`, etc.) to simulate a Lambda environment accurately if your code depends on `is-lambda`.
Always import it as a default export in ESM (`import isLambda from 'is-lambda';`) or use the CommonJS `require` syntax (`const isLambda = require('is-lambda');`).Change your import statement to `import isLambda from 'is-lambda';`.
Ensure you are assigning the result of `require('is-lambda')` directly to a variable: `const isLambda = require('is-lambda');`.No dependency data recorded yet.