project.json:

1//... 2{ 3 "name": "acme", 4 "$schema": "node_modules/nx/schemas/project-schema.json", 5 "sourceRoot": ".", 6 "projectType": "application", 7 "targets": { 8 //... 9 "serve": { 10 "executor": "@nx/next:server", 11 "defaultConfiguration": "production", 12 "options": { 13 "buildTarget": "acme:build", 14 "dev": true 15 } 16 } 17 //... 18 } 19} 20
1nx run acme:serve 2

Examples

For Next.js Standalone projects

This is the default configuration for Next.js standalone projects. Our @nx/next:server executor is integrated to use Next.js' CLI. You can read more about the serve options at Next.js CLI Options

1 "serve": { 2 "executor": "@nx/next:server", 3 "defaultConfiguration": "development", 4 "options": { 5 "buildTarget": "acme:build", 6 "dev": true 7 }, 8 "configurations": { 9 "development": { 10 "buildTarget": "acme:build:development", 11 "dev": true 12 }, 13 "production": { 14 "buildTarget": "acme:build:production", 15 "dev": false 16 } 17 } 18 }, 19

Options

buildTarget

Required
string

Target which builds the application.

port

number
Default: 4200

Port to listen on.

buildLibsFromSource

boolean
Default: true

Read buildable libraries from source instead of building them separately.

customServerTarget

string

Target which builds the custom server.

customServerHttps:

boolean

Enable HTTPS support for the custom server.

dev

boolean
Default: true

Serve the application in the dev mode.

experimentalHttps

boolean

Enable HTTPS support for the Next.js development server.

hostname

string

Hostname on which the application is served.

keepAliveTimeout

number

Max milliseconds to wait before closing inactive connection.

quiet

boolean
Default: false

Hide error messages containing server information.

staticMarkup

boolean
Default: false

Static markup.

turbo

boolean

Activate the incremental bundler for Next.js, which is implemented in Rust. Please note, this feature is exclusively available in development mode.