This boilerplate repository demonstrates how to deploy a Next.js application to AWS Lambda using Apex Up, complete with a custom Express server and a ready-to-use up.json configuration.
What is Next.js with AWS Lambda?
This is a minimal example project created by mattdamon108 that shows how to take a Next.js application and deploy it to AWS Lambda using the Apex Up CLI. It takes a Next.js codebase, adds a custom Express server in server.js, and produces a Lambda-deployable service through a up.json proxy configuration. The repository includes the IAM policy that Up requires, an .upignore rule, and a full up.json with Lambda memory, runtime, and stage settings.
Key Features
- Custom Express server — server.js defines routes for "/", "/about", and a catch-all handler using Next.js's getRequestHandler, allowing server-side rendering on Lambda.
- Apex Up deployment — A single
upcommand creates the AWS resources needed to run the app, based on the IAM policy andup.jsonincluded. - Configurable Lambda settings — The
up.jsonsets memory to 256 MB (minimum 128 MB), runtime to nodejs8.10, a 25-second proxy timeout, and a 15-second listen timeout. - AWS profile support — The example reads credentials from the
~/.aws/credentialsfile using the profile field, avoiding hardcoded keys. - Development and production stages — A stage called "development" runs
yarn devwhile the default stage runsnpm start, giving you parity between local and deployed behavior. - Cold start mitigation — The README links to a separate lambda-warmer repository to keep your Lambda functions warm and reduce response latency.
Who should use this template?
This template is aimed at developers who want to run Next.js on AWS Lambda and need a small, working reference rather than a full framework. It suits developers who are new to Apex Up, engineers who need a minimal custom server setup, and anyone who wants to see the exact IAM permissions Up requires to manage Lambda, API Gateway, CloudFront, and related services.
What can you do with it?
- Deploy a Next.js app to AWS Lambda — Follow the README's steps: install Up, configure your AWS profile, apply the IAM policy, run
yarn build, create.upignore, and executeup. - Run a local development server — Use
yarn dev, which runs the custom Express server with hot reloading through Next.js's dev mode, or thedevelopmentstage inup.json. - Customize the Lambda behavior — Adjust the memory, runtime, and environment variables in
up.jsonfor your own app's constraints. - Warm your Lambda functions — Integrate the linked lambda-warmer utility to ping your functions periodically and reduce cold-start delays.
How does the deployment work?
The workflow is fully documented in the README: install the Up CLI via curl, store AWS credentials in ~/.aws/credentials, attach the provided IAM policy, create an up.json that names your AWS profile and region, then build with yarn build. Because Up ignores dotfiles by default, the example adds an .upignore rule that negates .next so the compiled Next.js output is packaged. Finally, running up provisions the infrastructure and returns your serverless app URL.
FAQ
Do I need an AWS account to use this example?
Yes, the README instructs you to create an AWS account and set up IAM credentials with programmatic access so Up can deploy resources on your behalf.
What is the default Lambda memory configured here?
The example sets Lambda memory to 256 MB, with a comment noting the AWS minimum is 128 MB and Up's default is 512 MB.
How do I handle the Lambda cold start issue?
The author links to a separate lambda-warmer repository that keeps functions warm by sending periodic requests, reducing the latency of the first invocation.
Can I use this with the Next.js app using a custom server?
Yes, the entire example is based on a custom Express server; you would replace the routes in server.js with your own app's routes.







