1.0.1 • Published 1 year ago

build-next-serverless v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

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.

1.0.1

1 year ago

1.0.0

1 year ago