Deploying Next.js 14 to Netlify with Custom Build Settings

Walk through the process of deploying a Next.js 14 application on Netlify, including setting up build commands and publish directories.
// netlify.toml
  command = "npm run build"
  publish = "out"

  command = "npm run start"
This is the 'netlify.toml' file which is placed at the root of your Next.js project. It tells Netlify how to build and serve your Next.js project. The build command runs the build script from your package.json that typically builds a production version of your application. The publish directory is set to 'out', which is the default directory that Next.js exports the static files to with 'next export'.
// package.json
  "scripts": {
    "build": "next build && next export",
    "start": "next start"
This snippet should be part of your package.json's scripts property. It defines the 'build' script to both build the Next.js application and then export it to static HTML, which is compatible with Netlify's hosting. The 'start' script would be used for local development or for running the application in a different context.