Skip to content

annleefores/nextjs13-lambda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nextjs13-lambda

This repository provides a quick and easy way to deploy a simple Next.js app router application on AWS Lambda using aws-lambda-web-adapter.

Usage

Before you start, ensure that you have the following prerequisites installed:

Configuring Next.js App

In your Next.js app, update the next.config.js file to build the application for standalone deployment by adding output: 'standalone'. Additionally, include the assetPrefix property to specify the CDN DOMAIN for serving static files:

const nextConfig = {
    output: 'standalone',
    assetPrefix: 'https://<CDN_DOMAIN>',
    // other code
}

Build and deploy

Clone repo and build script

  • Clone this repository
https://github.com/annleefores/nextjs13-lambda.git
cd nextjs13-lambda
  • Navigate to the deploy script
cd packages/deploy
  • Install dependencies
npm i
  • Build deploy script
npm run build
  • To run deploy script in dev mode
npm run dev

Add env variable to tfvars

  • Create terraform.tfvars file based on the terraform.tfvars.example example file
  • Follow the comments to add required values
  • terraform.tfvars must be present in tf folder for the script to work
  • You can also use any of the env variable methods for Terraform listed here

Using external Next.js app

  • Build and deploy application
cd path/to/my/nextjs/app
node path/to/nextjs13-lambda/packages/deploy/build/deploy.js deploy
  • Delete deployment
cd path/to/nextjs-app
node path/to/nextjs13-lambda/packages/deploy/build/deploy.js delete
  • Building application
cd path/to/my/nextjs/app
node path/to/nextjs13-lambda/packages/deploy/build/deploy.js build

Using the example Next.js app

cd examples # from root directory
node ../packages/deploy/build/deploy.js <command>

About

A quick and easy way to deploy a simple Next.js application on AWS Lambda using aws-lambda-web-adapter

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published