Deploying Next.js 14 on Vercel
Provide a step-by-step example of deploying a Next.js 14 application to Vercel, including setting up the project and deployment settings.
// install vercel globally
npm i -g vercel
Installs Vercel's CLI globally using npm to enable deploying from the command line.
// navigate to the Next.js project directory
cd my-next-app
Change the current working directory to the directory of your Next.js application.
// Initialize a new Git repository if you haven't done so
// git init
// git add .
// git commit -m "Initial commit"
Initializes a new Git repository and commits the existing files. Only needed if you haven't set up a Git repository yet.
// Deploy the application using Vercel CLI
vercel
Deploys the Next.js application using the Vercel CLI. This will prompt for a series of configurations if you're deploying for the first time.
// Alternatively, push your code to a Git provider (GitHub, GitLab, Bitbucket)
// and import your project in Vercel through the web interface.
Another deployment method where you push your code to a Git repository and then import your project through the Vercel's dashboard.
// To deploy to production, use the '--prod' flag
vercel --prod
Deploys the application to production using Vercel CLI with the --prod flag.