set port nextjs

To set the port for a Next.js application, you can follow these steps:

  1. Open the Next.js project folder in your preferred code editor.

  2. Locate the next.config.js file in the root directory of your project. If the file doesn't exist, you can create one.

  3. Inside the next.config.js file, define the server object with a port property. This property will specify the port number you want to use for your Next.js application.

javascript // next.config.js module.exports = { server: { port: 3000, // Replace with the desired port number }, };

In the above example, the port property is set to 3000. You can change it to any available port number of your choice.

  1. Save the next.config.js file.

  2. If your Next.js application is running, stop the server (if applicable).

  3. Start your Next.js application again. It will now use the port number you specified in the next.config.js file.

By setting the port property in the next.config.js file, you can specify the port number for your Next.js application. This allows you to run the application on a specific port when starting the development server.