Skip to content

Construct for hosting Next.js apps with OpenNext #39

@rajikaimal

Description

@rajikaimal

Problem being solved

Next.js includes features that rely on serverless infrastructure, such as middleware, image optimization, and server-side rendering (SSR). Since Next.js is closely integrated with Vercel's infrastructure, these features are not natively supported elsewhere. As a solution, OpenNext can be used, which leverages AWS Lambda (or any other cloud serverless compute) to deploy Next.js builds.

Proposal

export class WebStack extends Construct {
    constructor(scope: Construct, id: string, props?: StackProps) {
        super(scope, id, props);
      
        const nextjs = new Nextjs(this, 'Nextjs', {
            nextjsPath: './web',
        });
       
        new CfnOutput(this, "CloudFrontDistributionDomain", {
           value: nextjs.distribution.distributionDomain,
        });
    }
}

Snippet taken from: https://github.com/jetbridge/cdk-nextjs
This construct doesn't support OpenNext v3, hence we'd probably have to go for our own implementation instead of re-using it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions