build-next-serverless
v1.0.1
Published
Build serverless functions from Next.js projects.
Downloads
4
Maintainers
Readme
Build Next.js for Serverless
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
Build
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
Important!
You should build your functions in a serverless alike environment. This ensures your
node_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.