flaviostutz / flaviostutz/cdk-practical-constructs

Construct for hosting Next.js apps with OpenNext

Open
#39 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
7
Forks
7
PR merge metrics
No merged PRs in 30d

Description

## 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](https://open-next.js.org/) can be used, which leverages AWS Lambda (or any other cloud serverless compute) to deploy Next.js builds.

## Proposal

```ts
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](https://github.com/jetbridge/cdk-nextjs) construct doesn't support OpenNext v3, hence we'd probably have to go for our own implementation instead of re-using it.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.