diff --git a/docs/platforms/javascript/guides/aws-lambda/index.mdx b/docs/platforms/javascript/guides/aws-lambda/index.mdx
index 62b203ce0806c..fa8592dba9e6e 100644
--- a/docs/platforms/javascript/guides/aws-lambda/index.mdx
+++ b/docs/platforms/javascript/guides/aws-lambda/index.mdx
@@ -20,12 +20,16 @@ On this page you'll get an overview how to install, configure and use Sentry in
## Installation
-Depending on your setup, there are different ways to install and use Sentry in your Lambda functions:
+Depending on your preferences, you can install Sentry in your Lambda functions using the [Sentry AWS Lambda Layer](./install/layer) (recommended) or the [Sentry AWS NPM package](./install/npm).
-- If your Lambda functions are running in CommonJS (CJS) using `require` syntax, [install the Sentry AWS Lambda Layer](./install/cjs-layer)
-- If your Lambda functions are running in EcmaScript Modules (ESM) using `import` syntax, [install the Sentry AWS NPM package](./install/esm-npm)
+### Should I use the Lambda Layer or the NPM package?
-If you're not sure which installation method to use or want an overview of all available options to use Sentry in your Lambda functions, read the [installation methods overview](./install).
+We generally recommend using the Lambda layer as it doesn't require you to deploy any Sentry dependency alongside your function.
+With the layer, you can achieve the same level of customization as with the NPM package.
+There are two reasons why you still might want to use the NPM package instead:
+
+1. You want to minimize lambda function size and tree-shake parts of the SDK code that you don't need. A related reason might be because you're transpiling your code and want to transpile your dependencies as well.
+2. You already use NPM packages and deploy `node_modules` with your function and you don't want to add a (or another) Lambda layer to your functions.
## Configuration
@@ -41,8 +45,10 @@ exports.handler = async (event, context) => {
};
```
-```javascript {filename:index.mjs}{tabTitle:ESM}{2}
-export const handler = async (event, context) => {
+```javascript {filename:index.mjs}{tabTitle:ESM}{4}
+import * as Sentry from "@sentry/aws-serverless";
+
+export const handler = Sentry.wrapHandler(async (event, context) => {
throw new Error("This is a test error");
-};
+}));
```
diff --git a/docs/platforms/javascript/guides/aws-lambda/install/cjs-npm.mdx b/docs/platforms/javascript/guides/aws-lambda/install/cjs-npm__v9.x.mdx
similarity index 100%
rename from docs/platforms/javascript/guides/aws-lambda/install/cjs-npm.mdx
rename to docs/platforms/javascript/guides/aws-lambda/install/cjs-npm__v9.x.mdx
diff --git a/docs/platforms/javascript/guides/aws-lambda/install/esm-npm.mdx b/docs/platforms/javascript/guides/aws-lambda/install/esm-npm__v9.x.mdx
similarity index 100%
rename from docs/platforms/javascript/guides/aws-lambda/install/esm-npm.mdx
rename to docs/platforms/javascript/guides/aws-lambda/install/esm-npm__v9.x.mdx
diff --git a/docs/platforms/javascript/guides/aws-lambda/install/img/env_vars.png b/docs/platforms/javascript/guides/aws-lambda/install/img/env_vars.png
new file mode 100644
index 0000000000000..76f5afe32d301
Binary files /dev/null and b/docs/platforms/javascript/guides/aws-lambda/install/img/env_vars.png differ
diff --git a/docs/platforms/javascript/guides/aws-lambda/install/index.mdx b/docs/platforms/javascript/guides/aws-lambda/install/index.mdx
index 2dc1f999deee6..e137ff46ea9ed 100644
--- a/docs/platforms/javascript/guides/aws-lambda/install/index.mdx
+++ b/docs/platforms/javascript/guides/aws-lambda/install/index.mdx
@@ -4,38 +4,12 @@ sidebar_order: 1
description: "Review all installation methods for using Sentry in AWS Lambda functions"
---
-
-## Which Installation Method Should I Use?
-
-Choosing the right installation method for using Sentry in your AWS Lambda functions depends on a couple of factors.
-
-Lambda functions can be written and executed either in CommonJS, using `require` syntax, or EcmaScript Modules (ESM), using `import` syntax.
-For Sentry to work correctly, you need to follow the guide for the format in which your functions are **executed**.
-
-### My Lambda function is written in TypeScript
-
-If you're using TypeScript, your lambda function is likely transpiled to CommonJS before running it. In this case, follow the [CommonJS instructions](#my-lambda-function-uses-require).
-Note that TypeScript can also be configured to output ESM, in which case you should follow the [ESM instructions](#my-lambda-function-uses-import).
-
-### My Lambda function uses `require`
-
-If you are using `require()` in your function, follow the CommonJS instructions. Choose between [using our Lambda Layer (recommended)](./cjs-layer) or [installing the Sentry AWS NPM package](./cjs-layer).
-
-### My Lambda function uses `import`
-
-If you're using `import` syntax in your function and you're _not_ transpiling the code to CommonJS, follow the [ESM instructions](./esm-npm).
-
-### Can I use the Lambda layer for ESM functions?
-
-At this time, the Lambda Layer is only available for CommonJS functions. If you're using ESM, you'll need to set up Sentry manually.
-We're working on an ESM lambda layer but need to solve several OpenTelemetry-related limitations first.
+
### Should I use the Lambda Layer or the NPM package?
-First off, at this time, you can only use the layer in CommonJS functions. If you're using ESM, you'll need to set up Sentry manually with the NPM package.
-
-We generally recommend to use the Lambda layer as it doesn't require you to deploy any Sentry dependency alongside your function.
-With using the layer, you can achieve the same level of customization as with the NPM package.
+We generally recommend using the Lambda layer as it doesn't require you to deploy any Sentry dependency alongside your function.
+With the layer, you can achieve the same level of customization as with the NPM package.
There are two reasons why you still might want to use the NPM package instead:
1. You want to minimize lambda function size and tree-shake parts of the SDK code that you don't need. A related reason might be because you're transpiling your code and want to transpile your dependencies as well.
diff --git a/docs/platforms/javascript/guides/aws-lambda/install/index__v9.x.mdx b/docs/platforms/javascript/guides/aws-lambda/install/index__v9.x.mdx
new file mode 100644
index 0000000000000..b025da974f33a
--- /dev/null
+++ b/docs/platforms/javascript/guides/aws-lambda/install/index__v9.x.mdx
@@ -0,0 +1,41 @@
+---
+title: Installation Methods
+sidebar_order: 1
+description: "Review all installation methods for using Sentry in AWS Lambda functions"
+---
+
+## Which Installation Method Should I Use?
+
+Choosing the right installation method for using Sentry in your AWS Lambda functions depends on a couple of factors.
+
+Lambda functions can be written and executed either in CommonJS, using `require` syntax, or EcmaScript Modules (ESM), using `import` syntax.
+For Sentry to work correctly, you need to follow the guide for the format in which your functions are **executed**.
+
+### My Lambda function is written in TypeScript
+
+If you're using TypeScript, your lambda function is likely transpiled to CommonJS before running it. In this case, follow the [CommonJS instructions](#my-lambda-function-uses-require).
+Note that TypeScript can also be configured to output ESM, in which case you should follow the [ESM instructions](#my-lambda-function-uses-import).
+
+### My Lambda function uses `require`
+
+If you are using `require()` in your function, follow the CommonJS instructions. Choose between [using our Lambda Layer (recommended)](./install/layer__v9.x) or [installing the Sentry AWS NPM package](./install/cjs-npm__v9.x).
+
+### My Lambda function uses `import`
+
+If you're using `import` syntax in your function and you're _not_ transpiling the code to CommonJS, follow the [ESM instructions](./install/esm-npm__v9.x).
+
+### Can I use the Lambda layer for ESM functions?
+
+At this time, the Lambda Layer is only available for CommonJS functions. If you're using ESM, you'll need to set up Sentry manually.
+We're working on an ESM lambda layer but need to solve several OpenTelemetry-related limitations first.
+
+### Should I use the Lambda Layer or the NPM package?
+
+First off, at this time, you can only use the layer in CommonJS functions. If you're using ESM, you'll need to set up Sentry manually with the NPM package.
+
+We generally recommend to use the Lambda layer as it doesn't require you to deploy any Sentry dependency alongside your function.
+With using the layer, you can achieve the same level of customization as with the NPM package.
+There are two reasons why you still might want to use the NPM package instead:
+
+1. You want to minimize lambda function size and tree-shake parts of the SDK code that you don't need. A related reason might be because you're transpiling your code and want to transpile your dependencies as well.
+2. You already use NPM packages and deploy `node_modules` with your function and you don't want to add a (or another) Lambda layer to your functions.
diff --git a/docs/platforms/javascript/guides/aws-lambda/install/layer.mdx b/docs/platforms/javascript/guides/aws-lambda/install/layer.mdx
new file mode 100644
index 0000000000000..f860b031b4417
--- /dev/null
+++ b/docs/platforms/javascript/guides/aws-lambda/install/layer.mdx
@@ -0,0 +1,178 @@
+---
+title: Lambda Layer
+description: "Learn how to add the Sentry Node Lambda Layer to use Sentry in your Lambda functions"
+sidebar_order: 1
+---
+
+The easiest way to get started with Sentry is to use the Sentry [Lambda Layer](https://docs.aws.amazon.com/lambda/latest/dg/adding-layers.html) instead of installing `@sentry/aws-serverless` with a package manager manually.
+If you follow this guide, you don't have to worry about deploying Sentry dependencies alongside your function code.
+
+## Prerequisites
+
+Before you begin, make sure you have the following:
+
+- You have a Lambda function deployed in AWS.
+- You know the AWS region that your function is deployed to.
+
+## 1. Add the Sentry Lambda Layer
+
+Add the Sentry Layer by navigating to your Lambda function. Select **Layers**, then **Add a Layer**.
+
+
+
+**Specify an ARN** tab as illustrated:
+
+
+
+Finally, set the region and copy the provided ARN value into the input.
+
+
+
+
+
+## 2. Setup Options
+
+Choose your setup method based on your Lambda function type:
+
+
+
+The setup instructions you should follow depend on how your function **runs** at runtime, not how it's written in your source code.
+
+- **Use CommonJS instructions** if your function runs with CommonJS modules (uses `require()` and `module.exports` at runtime)
+- **Use ESM instructions** if your function runs with ES modules (uses `import`/`export` at runtime)
+
+**Important:** Even if you write your code with `import`/`export` syntax, your function might still run as CommonJS if you're using TypeScript or a build tool that compiles to CommonJS. Check your build output or Lambda runtime configuration to determine which applies to your function.
+
+
+
+### Option A: Automatic Setup
+
+**CommonJS functions** support fully automatic setup using environment variables - both SDK initialization and handler wrapping are handled automatically.
+
+**ESM functions** support automatic SDK initialization via environment variables, but require manual handler wrapping.
+
+In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/).
+
+Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below.
+
+
+
+Set the following environment variables in your Lambda function configuration:
+
+```bash {tabTitle:CommonJS}
+NODE_OPTIONS="--require @sentry/aws-serverless/awslambda-auto"
+SENTRY_DSN="___PUBLIC_DSN___"
+# ___PRODUCT_OPTION_START___ performance
+SENTRY_TRACES_SAMPLE_RATE="1.0"
+# ___PRODUCT_OPTION_END___ performance
+```
+
+```bash {tabTitle:ESM}
+NODE_OPTIONS="--import @sentry/aws-serverless/awslambda-auto"
+SENTRY_DSN="___PUBLIC_DSN___"
+# ___PRODUCT_OPTION_START___ performance
+SENTRY_TRACES_SAMPLE_RATE="1.0"
+# ___PRODUCT_OPTION_END___ performance
+```
+
+To set environment variables, navigate to your Lambda function, select **Configuration**, then **Environment variables**:
+
+
+
+
+
+You'll also need to manually wrap your handler as shown below:
+
+```javascript {filename:index.mjs}
+import * as Sentry from "@sentry/aws-serverless";
+
+export const handler = Sentry.wrapHandler(async (event, context) => {
+ // Your handler code
+});
+```
+
+
+
+### Option B: Manual Setup
+
+Instead of using environment variables, you can manually initialize the SDK and wrap your handler in code. This approach works for both CommonJS and ESM functions and allows for further customization of the SDK setup.
+
+Note that you don't have to actually install an NPM package for this to work, as the package is already included in the Lambda Layer.
+
+#### For CommonJS Lambda Functions
+
+```javascript {filename:index.js}
+const Sentry = require("@sentry/aws-serverless");
+
+Sentry.init({
+ dsn: "___PUBLIC_DSN___",
+
+ // Adds request headers and IP for users, for more info visit:
+ // https://docs.sentry.io/platforms/javascript/guides/aws-lambda/configuration/options/#sendDefaultPii
+ sendDefaultPii: true,
+ // ___PRODUCT_OPTION_START___ performance
+
+ // Add Tracing by setting tracesSampleRate and adding integration
+ // Set tracesSampleRate to 1.0 to capture 100% of transactions
+ // We recommend adjusting this value in production
+ // Learn more at
+ // https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate
+ tracesSampleRate: 1.0,
+ // ___PRODUCT_OPTION_END___ performance
+});
+
+// Your package imports
+
+exports.handler = Sentry.wrapHandler(async (event, context) => {
+ // Your handler code
+});
+```
+
+It's important to add both, the `Sentry.init` call outside the handler function and the `Sentry.wrapHandler` wrapper around your function to automatically catch errors and performance data. Make sure that the `Sentry.init` call and the import statement are at the very top of your file before any other imports.
+
+#### For ESM Lambda Functions
+
+First, wrap your handler:
+
+```javascript {filename:index.mjs}{1,3}
+import * as Sentry from "@sentry/aws-serverless";
+
+export const handler = Sentry.wrapHandler(async (event, context) => {
+ // Your handler code
+});
+```
+
+Due to ESM limitations, you need to initialize the SDK in a separate file and load it before your function starts.
+
+Create a new file, for example `instrument.mjs` to initialize the SDK:
+
+```javascript {filename:instrument.mjs}
+import * as Sentry from "@sentry/aws-serverless";
+
+Sentry.init({
+ dsn: "___PUBLIC_DSN___",
+
+ // Adds request headers and IP for users, for more info visit:
+ // https://docs.sentry.io/platforms/javascript/guides/aws-lambda/configuration/options/#sendDefaultPii
+ sendDefaultPii: true,
+ // ___PRODUCT_OPTION_START___ performance
+
+ // Add Tracing by setting tracesSampleRate and adding integration
+ // Set tracesSampleRate to 1.0 to capture 100% of transactions
+ // We recommend adjusting this value in production
+ // Learn more at
+ // https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate
+ tracesSampleRate: 1.0,
+ // ___PRODUCT_OPTION_END___ performance
+});
+```
+
+##### Load the SDK
+
+To load the SDK before your function starts, you need to preload the `instrument.mjs` by setting the `NODE_OPTIONS` environment variable:
+
+```bash
+NODE_OPTIONS="--import ./instrument.mjs"
+```
+
+That's it — make sure to re-deploy your function and you're all set!
diff --git a/docs/platforms/javascript/guides/aws-lambda/install/cjs-layer__v7.x.mdx b/docs/platforms/javascript/guides/aws-lambda/install/layer__v7.x.mdx
similarity index 100%
rename from docs/platforms/javascript/guides/aws-lambda/install/cjs-layer__v7.x.mdx
rename to docs/platforms/javascript/guides/aws-lambda/install/layer__v7.x.mdx
diff --git a/docs/platforms/javascript/guides/aws-lambda/install/cjs-layer__v8.x.mdx b/docs/platforms/javascript/guides/aws-lambda/install/layer__v8.x.mdx
similarity index 100%
rename from docs/platforms/javascript/guides/aws-lambda/install/cjs-layer__v8.x.mdx
rename to docs/platforms/javascript/guides/aws-lambda/install/layer__v8.x.mdx
diff --git a/docs/platforms/javascript/guides/aws-lambda/install/cjs-layer.mdx b/docs/platforms/javascript/guides/aws-lambda/install/layer__v9.x.mdx
similarity index 95%
rename from docs/platforms/javascript/guides/aws-lambda/install/cjs-layer.mdx
rename to docs/platforms/javascript/guides/aws-lambda/install/layer__v9.x.mdx
index 948a081ecb756..ed3a3dd1a2b45 100644
--- a/docs/platforms/javascript/guides/aws-lambda/install/cjs-layer.mdx
+++ b/docs/platforms/javascript/guides/aws-lambda/install/layer__v9.x.mdx
@@ -31,9 +31,11 @@ Add the Sentry Layer by navigating to your Lambda function. Select **Layers**, t

-Finally, set the region and copy the provided ARN value into the input.
+Modify and copy the ARN value for your region into the input, e.g. for region `us-west-1` and the current v9 Lambda layer version `56`:
-
+```
+arn:aws:Lambda:us-west-1:943013980633:layer:SentryNodeServerlessSDKv9:56
+```
@@ -74,12 +76,12 @@ const Sentry = require("@sentry/aws-serverless");
Sentry.init({
dsn: "___PUBLIC_DSN___",
-
+
// Adds request headers and IP for users, for more info visit:
// https://docs.sentry.io/platforms/javascript/guides/aws-lambda/configuration/options/#sendDefaultPii
sendDefaultPii: true,
// ___PRODUCT_OPTION_START___ performance
-
+
// Add Tracing by setting tracesSampleRate and adding integration
// Set tracesSampleRate to 1.0 to capture 100% of transactions
// We recommend adjusting this value in production
diff --git a/docs/platforms/javascript/guides/aws-lambda/install/npm.mdx b/docs/platforms/javascript/guides/aws-lambda/install/npm.mdx
new file mode 100644
index 0000000000000..97f305b884617
--- /dev/null
+++ b/docs/platforms/javascript/guides/aws-lambda/install/npm.mdx
@@ -0,0 +1,237 @@
+---
+title: NPM Package
+description: "Learn how to install the Sentry AWS NPM package to use Sentry in your Lambda functions"
+sidebar_order: 2
+---
+
+In this guide you will learn how to set up the `@sentry/aws-serverless` SDK for AWS Lambda functions using NPM.
+We recommend starting the SDK automatically via environment variables so that you only have to make minimal code changes to your lambda function.
+If you need more control over the SDK setup, you can also [initialize the SDK in code](#option-b-manual-setup).
+
+However, you need to modify your code and deploy the Sentry dependencies alongside your function code. If you're looking for the most simple way to set up Sentry, use the [Lambda Layer](../layer) instead.
+
+## 1. Prerequisites
+
+Before you begin, make sure you have the following:
+
+- You have a Lambda function deployed in AWS.
+- You're able to deploy dependencies (i.e. `node_modules`) alongside your function code to AWS Lambda.
+
+
+
+The setup instructions you should follow depend on how your Lambda function **runs** at runtime, not how it's written in your source code.
+
+- **Use CommonJS instructions** if your function runs with CommonJS modules (uses `require()` and `module.exports` at runtime)
+- **Use ESM instructions** if your function runs with ES modules (uses `import`/`export` at runtime)
+
+**Important:** Even if you write your code with `import`/`export` syntax, your function might still run as CommonJS if you're using TypeScript or a build tool that compiles to CommonJS. Check your build output or Lambda runtime configuration to determine which applies to your function.
+
+
+
+## 2. Install
+
+In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). You can also collect and analyze performance profiles from real users with [profiling](/product/explore/profiling/).
+
+Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below.
+
+
+
+Install the `@sentry/aws-serverless` SDK using a package manager of your choice:
+
+
+
+```bash {tabTitle:npm}
+npm install @sentry/aws-serverless
+```
+
+```bash {tabTitle:yarn}
+yarn add @sentry/aws-serverless
+```
+
+```bash {tabTitle:pnpm}
+pnpm add @sentry/aws-serverless
+```
+
+
+
+
+
+```bash {tabTitle:npm}
+npm install @sentry/aws-serverless @sentry/profiling-node
+```
+
+```bash {tabTitle:yarn}
+yarn add @sentry/aws-serverless @sentry/profiling-node
+```
+
+```bash {tabTitle:pnpm}
+pnpm add @sentry/aws-serverless @sentry/profiling-node
+```
+
+
+
+## 3. Setup Options
+
+Choose your setup method based on your Lambda function type:
+
+### Option A: Automatic Setup
+
+**CommonJS functions** support fully automatic setup using environment variables - both SDK initialization and handler wrapping are handled automatically.
+
+**ESM functions** support automatic SDK initialization via environment variables, but require manual handler wrapping.
+
+Set the following environment variables in your Lambda function configuration:
+
+```bash {tabTitle:CommonJS}
+NODE_OPTIONS="--require @sentry/aws-serverless/awslambda-auto"
+SENTRY_DSN="___PUBLIC_DSN___"
+# ___PRODUCT_OPTION_START___ performance
+SENTRY_TRACES_SAMPLE_RATE="1.0"
+# ___PRODUCT_OPTION_END___ performance
+```
+
+```bash {tabTitle:ESM}
+NODE_OPTIONS="--import @sentry/aws-serverless/awslambda-auto"
+SENTRY_DSN="___PUBLIC_DSN___"
+# ___PRODUCT_OPTION_START___ performance
+SENTRY_TRACES_SAMPLE_RATE="1.0"
+# ___PRODUCT_OPTION_END___ performance
+```
+
+To set environment variables, navigate to your Lambda function, select **Configuration**, then **Environment variables**:
+
+
+
+
+
+You'll also need to manually wrap your handler as shown below:
+
+```javascript {tabTitle:ESM} {filename:index.mjs}{1,3}
+import * as Sentry from "@sentry/aws-serverless";
+
+export const handler = Sentry.wrapHandler(async (event, context) => {
+ // Your handler code
+});
+```
+
+
+
+That's it - make sure to re-deploy your function and you're all set!
+
+### Option B: Manual Setup
+
+To further customize the SDK setup, you can also manually initialize the SDK in your lambda function. The benefit of this installation method is that you can fully customize your Sentry SDK setup in a `Sentry.init` call.
+
+#### For CommonJS Lambda Functions
+
+You can initialize the SDK directly in your main handler file:
+
+```javascript {tabTitle:CommonJS} {filename:index.js}
+const Sentry = require("@sentry/aws-serverless");
+// ___PRODUCT_OPTION_START___ profiling
+const { nodeProfilingIntegration } = require("@sentry/profiling-node");
+
+// ___PRODUCT_OPTION_END___ profiling
+Sentry.init({
+ dsn: "___PUBLIC_DSN___",
+
+ // Adds request headers and IP for users, for more info visit:
+ // https://docs.sentry.io/platforms/javascript/guides/aws-lambda/configuration/options/#sendDefaultPii
+ sendDefaultPii: true,
+ // ___PRODUCT_OPTION_START___ profiling
+ integrations: [nodeProfilingIntegration()],
+
+ // ___PRODUCT_OPTION_END___ profiling
+ // ___PRODUCT_OPTION_START___ performance
+ // Add Tracing by setting tracesSampleRate and adding integration
+ // Set tracesSampleRate to 1.0 to capture 100% of transactions
+ // We recommend adjusting this value in production
+ // Learn more at
+ // https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate
+ tracesSampleRate: 1.0,
+ // ___PRODUCT_OPTION_END___ performance
+ // ___PRODUCT_OPTION_START___ profiling
+
+ // Set sampling rate for profiling - this is relative to tracesSampleRate
+ profilesSampleRate: 1.0,
+ // ___PRODUCT_OPTION_END___ profiling
+});
+
+// Your package imports
+
+exports.handler = Sentry.wrapHandler(async (event, context) => {
+ // Your handler code
+});
+```
+
+It's important to add both, the `Sentry.init` call outside the handler function and the `Sentry.wrapHandler` wrapper around your function to automatically catch errors and performance data. Make sure that the `Sentry.init` call and the import statement are at the very top of your file before any other imports.
+
+#### For ESM Lambda Functions
+
+First, wrap your handler:
+
+```javascript {tabTitle:ESM} {filename:index.mjs}{1,3}
+import * as Sentry from "@sentry/aws-serverless";
+
+export const handler = Sentry.wrapHandler(async (event, context) => {
+ // Your handler code
+});
+```
+
+Due to ESM limitations, you need to initialize the SDK in a separate file and load it before your function starts.
+
+Create a new file, for example `instrument.mjs` to initialize the SDK:
+
+```javascript {tabTitle:ESM} {filename:instrument.mjs}
+import * as Sentry from "@sentry/aws-serverless";
+// ___PRODUCT_OPTION_START___ profiling
+import { nodeProfilingIntegration } from "@sentry/profiling-node";
+// ___PRODUCT_OPTION_END___ profiling
+
+Sentry.init({
+ dsn: "___PUBLIC_DSN___",
+
+ // Adds request headers and IP for users, for more info visit:
+ // https://docs.sentry.io/platforms/javascript/guides/aws-lambda/configuration/options/#sendDefaultPii
+ sendDefaultPii: true,
+ // ___PRODUCT_OPTION_START___ profiling
+ integrations: [nodeProfilingIntegration()],
+ // ___PRODUCT_OPTION_END___ profiling
+ // ___PRODUCT_OPTION_START___ performance
+
+ // Add Tracing by setting tracesSampleRate and adding integration
+ // Set tracesSampleRate to 1.0 to capture 100% of transactions
+ // We recommend adjusting this value in production
+ // Learn more at
+ // https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate
+ tracesSampleRate: 1.0,
+ // ___PRODUCT_OPTION_END___ performance
+ // ___PRODUCT_OPTION_START___ profiling
+
+ // Set sampling rate for profiling - this is relative to tracesSampleRate
+ profilesSampleRate: 1.0,
+ // ___PRODUCT_OPTION_END___ profiling
+});
+```
+
+##### Load the SDK
+
+To load the SDK before your function starts, you need to set the `NODE_OPTIONS` environment variable:
+
+```bash {tabTitle:ESM}
+NODE_OPTIONS="--import ./instrument.mjs"
+```
+
+To set environment variables, navigate to your Lambda function, select **Configuration**, then **Environment variables**.
+
+That's it - make sure to re-deploy your function and you're all set!
+
+## Using the v7 SDK
+
+The instructions above are written for the latest SDK version.
+
+**For CommonJS functions:** In SDK versions prior to version 8, the `@sentry/aws-serverless` package was called `@sentry/serverless`. If you are using an older version, you can follow this guide but replace the package with `@sentry/serverless`.
+
+**For ESM functions:** The v7 `@sentry/serverless` SDK does not work correctly with ESM-based Lambda functions. Please upgrade to the latest SDK and follow the instructions above.
diff --git a/docs/platforms/javascript/guides/aws-lambda/install/npm__v9.x.mdx b/docs/platforms/javascript/guides/aws-lambda/install/npm__v9.x.mdx
new file mode 100644
index 0000000000000..b6fec3a516705
--- /dev/null
+++ b/docs/platforms/javascript/guides/aws-lambda/install/npm__v9.x.mdx
@@ -0,0 +1,20 @@
+---
+title: NPM Package
+description: "Learn how to install the Sentry AWS NPM package to use Sentry in your Lambda functions"
+sidebar_order: 2
+---
+
+Based on whether your Lambda function runs in CommonJS or ESM, you need to follow the instructions for the corresponding module system.
+
+## My Lambda function is written in TypeScript
+
+If you're using TypeScript, your lambda function is likely transpiled to CommonJS before running it. In this case, follow the [CommonJS instructions](./cjs-npm__v9.x).
+Note that TypeScript can also be configured to output ESM, in which case you should follow the [ESM instructions](./esm-npm__v9.x).
+
+## My Lambda function uses `require`
+
+If you are using `require()` in your function, follow the [CommonJS instructions](./cjs-npm__v9.x).
+
+## My Lambda function uses `import`
+
+If you're using `import` syntax in your function and you're _not_ transpiling the code to CommonJS, follow the [ESM instructions](./esm-npm__v9.x).