AWS Lambda
Deploy Nitro apps to AWS Lambda.
Preset: aws_lambda
Nitro provides a built-in preset to generate output compatible with AWS Lambda.
The output entrypoint in .output/server/index.mjs is compatible with the AWS Lambda format.
It can be used programmatically or as part of a deployment.
import { handler } from './.output/server'
// Use programmatically
const { statusCode, headers, body } = handler({ rawPath: '/' })
Inlining chunks
By default, Nitro output uses dynamic chunks to lazy-load code only when needed. However, this is not always ideal for performance (see the discussion in nitrojs/nitro#650). You can enable chunk inlining using the inlineDynamicImports config.
nitro.config.ts
import { defineConfig } from "nitro";
export default defineConfig({
inlineDynamicImports: true
});
Response streaming
To enable response streaming, set the awsLambda.streaming flag:
nitro.config.ts
import { defineConfig } from "nitro";
export default defineConfig({
awsLambda: {
streaming: true
}
});