Next.js Serverless Build Tool

3.0.1 · active · verified Sun Apr 19

ns-build is a CLI utility designed to simplify the build process for Next.js applications intended for serverless deployment on AWS using Terraform. It primarily functions as a bash script, automating the steps required to prepare a Next.js project (specifically those configured with `output: 'standalone'`) for deployment. The current stable version is 3.1.1. It maintains a consistent release cadence with updates to support newer Next.js versions (e.g., v15, v16) and Node.js runtimes (e.g., Node 22, Node 24) on AWS Lambda. Its key differentiator is its tight integration with the `nextjs-serverless` Terraform module, providing a streamlined workflow from build to infrastructure deployment without requiring manual asset compilation or environment setup for AWS Lambda and CloudFront distributions.

Common errors

Warnings

Install

Quickstart

Demonstrates the package.json setup and `next.config.js` configuration for using `ns-build` with a Next.js project, followed by the build command.

{
  "name": "my-nextjs-app",
  "version": "0.1.0",
  "scripts": {
    "build": "ns-build build"
  },
  "dependencies": {
    "next": "^16.0.0",
    "react": "^18",
    "react-dom": "^18"
  },
  "devDependencies": {
    "ns-build": "^3.0.1"
  }
}
// next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
  output: 'standalone',
};
module.exports = nextConfig;

// Run the build command
// npm install
// npm run build

// The output will be in ./.ns-build and is intended to be used by the
// 'nextjs-serverless' Terraform module for deployment to AWS.

view raw JSON →