Nuxt/docs/content/3.docs/3.deployment/99.presets/lambda.md
2021-10-11 19:18:38 +02:00

1.1 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 explicity 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

Entrypoint

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

This entrypoint is compatible with AWS Lambda and Netlify Functions.

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

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

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