Build your Next.js projects for deployment in serverless environments such as AWS Lambda.
✔️ No installation required
✔️ Minimal base package size (~25mb with Next 14)
✔️ Test your build in server mode
-
Enable standalone mode in your
next.config.mjs
:... const nextConfig = { + output: "standalone", }; ...
-
Run the build command in your project folder:
cd my-next-app npx build-next-serverless
The serverless function will be built into dist
directory.
You can test the build using the server mode with: node dist/server.js
You should build your functions in a serverless alike environment.
This ensures yournode_modules
are compatible with the target serverless runtime.
To achieve that, we recommend you to use a deployment tool likeAWS SAM CLI
There is an an example showing how to incorporate AWS SAM CLI
into your workflow.