Next.js › Deployment
How do you build and run a Next.js application in production outside of Vercel, such as on your own server?
IntermediateAnswer
You run the build command to generate an optimized production build, then use the start command to run a Node.js server that serves that build, making sure any required environment variables are set on the server before starting it.
# Build the application
npm run build
# Start the production server
npm run startReal-world example A company running its own infrastructure builds its Next.js application, copies the build output to their server, and runs the start command behind a process manager to keep the app running reliably.