UNPKG

open-next-cdk

Version:

Deploy a NextJS app using OpenNext packaging to serverless AWS using CDK

125 lines (124 loc) 4.53 kB
import { ICertificate } from 'aws-cdk-lib/aws-certificatemanager'; import { ErrorResponse } from 'aws-cdk-lib/aws-cloudfront'; import { IHostedZone } from 'aws-cdk-lib/aws-route53'; export declare type CompressionLevel = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; /** * Common props shared across NextJS-related CDK constructs. */ export interface NextjsBaseProps { /** * Relative path to the OpenNext package named `.open-next` by default. * * One of `openNextPath` or `nextJsPath` must be supplied. */ readonly openNextPath?: string; /** * Relative path to the directory where the NextJS project is located. * Can be the root of your project (`.`) or a subdirectory (`packages/web`). * * One of `openNextPath` or `nextJsPath` must be supplied. */ readonly nextJsPath?: string; /** * Relative path to the directory where the NextJS project is located. * Can be the root of your project (`.`) or a subdirectory (`packages/web`). * * One of `openNextPath`, `nextJsPath` or `nextjsPath` must be supplied. * * @deprecated use `nextJsPath` instead */ readonly nextjsPath?: string; /** * The directory to execute `npm run build` from. By default, it is `nextjsPath`. * Can be overridden, particularly useful for monorepos where `build` is expected to run * at the root of the project. */ readonly buildPath?: string; /** * Custom environment variables to pass to the NextJS build and runtime. */ readonly environment?: Record<string, string>; /** * Used in conjunction with nextJsPath to skip building NextJS * app and assume .open-next folder already exists. * Useful when using `next dev` for local development. * * @deprecated use `openNextPath` instead */ readonly isPlaceholder?: boolean; /** * Directory to store temporary build files in. * Defaults to os.tmpdir(). */ readonly tempBuildDir?: string; /** * Optional value for NODE_ENV during build and runtime. */ readonly nodeEnv?: string; /** * Optional value used to install NextJS node dependencies. * It defaults to 'npx --yes open-next@1 build' */ readonly buildCommand?: string; /** * 0 - no compression, fastest * 9 - maximum compression, slowest * @default 1 */ readonly compressionLevel?: CompressionLevel; /** * Less build output. */ readonly quiet?: boolean; /** * Optional arn for the sharp lambda layer. * If omitted, the layer will be created. */ readonly sharpLayerArn?: string; } export interface BaseSiteDomainProps { /** * The domain to be assigned to the website URL (ie. domain.com). * * Supports domains that are hosted either on [Route 53](https://aws.amazon.com/route53/) or externally. */ readonly domainName: string; /** * An alternative domain to be assigned to the website URL. Visitors to the alias will be redirected to the main domain. (ie. `www.domain.com`). * * Use this to create a `www.` version of your domain and redirect visitors to the root domain. */ readonly domainAlias?: string; /** * Specify additional names that should route to the Cloudfront Distribution. */ readonly alternateNames?: string[]; /** * Set this option if the domain is not hosted on Amazon Route 53. */ readonly isExternalDomain?: boolean; /** * Import the underlying Route 53 hosted zone. */ readonly hostedZone?: IHostedZone; /** * Import the certificate for the domain. By default, SST will create a certificate with the domain name. The certificate will be created in the `us-east-1`(N. Virginia) region as required by AWS CloudFront. * * Set this option if you have an existing certificate in the `us-east-1` region in AWS Certificate Manager you want to use. */ readonly certificate?: ICertificate; } export interface BaseSiteReplaceProps { readonly files: string; readonly search: string; readonly replace: string; } export interface BaseSiteEnvironmentOutputsInfo { readonly path: string; readonly stack: string; readonly environmentOutputs: { [key: string]: string; }; } export declare function buildErrorResponsesForRedirectToIndex(indexPage: string): ErrorResponse[]; export declare function buildErrorResponsesFor404ErrorPage(errorPage: string): ErrorResponse[];