Nuxt/docs/content/3.docs/8.deployment/99.presets/lambda.md
Daniel Roe 1a39eff502
docs: update migration guide for nuxt 3 (#3819)
Co-authored-by: Dan Pastori <dan@521dimensions.com>
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
Co-authored-by: pooya parsa <pyapar@gmail.com>
2022-03-30 19:32:30 +02:00

1.3 KiB

Lambda function

Discover the Lambda function preset with Nitro to deploy Nuxt to any lambda-compatible serverless platform.

::alert{icon=IconPresets} Back to presets list. ::

Usage

You can use the Nuxt config to explicitly set the preset to use:

export default {
  nitro: {
    preset: 'lambda'
  }
}

Or directly use the NITRO_PRESET environment variable when running nuxt build:

NITRO_PRESET=lambda npx nuxt build

::alert AWS Lambda defaults to payload version v2. This Nitro preset supports both v1 and v2 payloads. ::

Entrypoint

When running nuxt build with the Lambda preset, the result will be an entry point that exports a handler function that responds to an event and returns a response.

This entry point is compatible with AWS Lambda and Netlify Functions.

It can be used programmatically or as part of a deployment.

import { handler } from './.output/server'

// Use programmatically
const { statusCode, headers, body } = handler({ rawPath: '/' })