build-next-serverless

1.0.1 • Public • Published

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

  1. Enable standalone mode in your next.config.mjs:

    ...
    const nextConfig = {
    +    output: "standalone",
    };
    ...
  2. 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 like AWS SAM CLI

There is an an example showing how to incorporate AWS SAM CLI into your workflow.

Package Sidebar

Install

npm i build-next-serverless

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

9.87 kB

Total Files

4

Last publish

Collaborators

  • kumarasinghe