Deploy a NextJS application using AWS CDK
Key metrics and engagement data
Repository has been active for N/A
Looks like this repository is a hidden gem!
No stargazers yet. Why not be the first to give it a star?
Check back soon, we will update it in background!
⭐0
Want deeper insights? Explore GitObs.com
A CDK construct to deploy a NextJS app using AWS CDK. Supported NextJs versions: >=12.3.0+ (includes 13.0.0+)
Uses the standalone output build mode.
ts1import { App, Stack, StackProps } from 'aws-cdk-lib';2import { Construct } from 'constructs';3import { Nextjs } from 'cdk-nextjs-standalone';45class WebStack extends Stack {6 constructor(scope: Construct, id: string, props?: StackProps) {7 super(scope, id, props);8 const nextjs = new Nextjs(this, 'Nextjs', {9 nextjsPath: './web', // relative path from your project root to NextJS10 });11 new CfnOutput(this, 'CloudFrontDistributionDomain', {12 value: nextjs.distribution.distributionDomain,13 });14 }15}1617const app = new App();18new WebStack(app, 'web');
public/
folder. CloudFront has a soft limit of 25 cache behaviors per distribution. Therefore, it's recommended to include all assets that can be under a top level folder like public/static/
. Learn more in open-next docs here.Available on Construct Hub.
See example CDK apps here including:
To deploy an example, make sure to read the README.md
We're in the #aws channel on the Open-Next Discord.
Deploys a NextJs static site with server-side rendering and API support. Uses AWS lambda and CloudFront.
There is a new (since Next 12) standalone output mode which uses output tracing to generate a minimal server and static files. This standalone server can be converted into a CloudFront distribution and a lambda handler that handles SSR, API, and routing.
The CloudFront default origin first checks S3 for static files and falls back to an HTTP origin using a lambda function URL.
This approach is most compatible with new NextJs features such as ESM configuration, middleware, next-auth, and React server components ("appDir").
The unmaintained @serverless-nextjs project uses the deprecated serverless
NextJs build target which prevents the use of new features.
This construct was created to use the new standalone
output build and newer AWS features like lambda function URLs and fallback origins.
You may want to look at Serverless Stack and its NextjsSite construct for an improved developer experience if you are building serverless applications on CDK.
Built on top of open-next, which was partially built using the original core of cdk-nextjs-standalone.
See Contribute.
See Major Changes.