A CLI to build artifacts to deploy Next.js on AWS using Cloudfront and Lambda@edge
npm i -g aws-next
Build your Next.js app (e.g. next build
), then navigate to the root of your Next.js project and run:
$ aws-next
This will output the build artifacts under .aws-next
folder. The artifacts are meant to be deployed using AWS CDK.
s3
: contains static assets to be deployed to AWS S3default-lambda
: contains the lambda@edge code to handle all page and assets requestsapi-lambda
: contains the lambda@edge code to handle all api requests
Lambda@edge does not support environment variables. To overcome this you can bundle your enviroment variables into your Next.js deploy. Alternatively, this CLI injects into process.env
custom headers defined from the Cloudfront distribution that starts with X-ENV-
.
Based on the contribution, format your commit message this way so that the version is correctly bumped:
- If the contribution is a breaking change, put
BREAKING CHANGE
ormajor
somewhere in your commit. - If the contribution is a new feature format your message like this "
feat
: added this new cool stuff". You can also useminor
orfeature
- All other changes will increment the patch version
In case you might want to skip version bumping just add [skip ci]
to your commit.
To publish a new version to npm, just create a Github release. Once you create the release a Github workflow will take care of the publishing process.