Documentation
NextJS (Legacy)

NextJS (Legacy mode)

NextJS is a full-stack framework that makes it easy to deploy web applications in a single codebase.

💡

For compatibility with modern versions of NextJS next >= 13.5.4, please use the standalone output mode.

What's the difference between nextjs and nextjs-standalone mode?

The original NextJS mode initially released with Airbase (and Launchpad) provides out-of-the-box support for many NextJS projects, and a great developer experience.

Engineers and teams can clone a codebase and deploy it to Airbase without further configuration, relying on the Airbase build and packaging functions to create a deployable package.

NextJS 13.4.x introduced a new stable feature called standalone mode (which wasn't originally available when Airbase first launched).

Standalone mode means that the NextJS framework and tools is responsible for creating a deployable artifact as part of the build step.

Read more about the NextJS output mode here (opens in a new tab).

How to decide between nextjs and nextjs-standalone mode?

  • If you're using next <= 13.3.x, use nextjs.
  • If you're using next <= 13.4.9, use nextjs.
  • If one or more of the following apply, use nextjs-standalone:
    • Using next >= 13.5.4 (no longer compatible with nextjs mode due to packaging changes)
    • Deployment artifact (airbase.zip) nearing 50 MB limit (standalone produces more efficient output)
    • Issues with dependency tracing using nextjs mode: (standalone has first-class support)
    • Find out how to use nextjs-standalone here.

Instructions

Ensure that NextJS is configured to use the default output mode

Remove the output: "standalone" option from the project's next.config.js file:

  // next.config.js
 
  const nextConfig = {
    ...
-   output: 'standalone',
    ...
  };
 
  module.exports = nextConfig;

Configure Airbase to use the NextJS Framework

Run airbase configure and select nextjs from the list of frameworks when prompted.

user@laptop example % airbase configure
 
Configuring project for Airbase
? Project Name: example
? Framework: nextjs
? Command to build production deployment: npm run build
? Command to start production server: next start
 
{
  name: "example"
  framework: "nextjs"
  scripts: {
    build: "npm run build"
    start: "next start"
  }
}
 
? Save configuration? Yes
 
Configuration saved in ./airbase.json
Run airbase build to create a deployment package.
user@laptop example %

The default values for the build and start commands are provided in this sample airbase.json file:

{
  "name": "example",
  "framework": "nextjs",
  "scripts": {
    "build": "npm run build",
    "start": "next start"
  }
}

Build and deploy your application

Now that the NextJS and Airbase configuration has been updated, run airbase build as normal to build your application.

Then deploy the application with airbase deploy.