LogoMkSaaS Docs

Deploying on Vercel

Learn how to deploy your project to the Vercel platform

This guide will help you deploy your project to the Vercel platform. Since the project is built with Next.js, Vercel, as the creator of Next.js, provides the best developer experience and performance optimization.

Prerequisites

Before deploying your project, make sure you have:

  1. A Git repository containing your project code (like GitHub, GitLab, or Bitbucket)
  2. A Vercel account, sign up here if you don't have one
  3. Environment variables configured for the production environment

Deployment Steps

Push Code to Git Repository

Ensure your code is pushed to a code repository on GitHub, GitLab, or Bitbucket.

Connect to Vercel

  • Log in to the Vercel Console
  • Click the "Add New Project" or "New Project" button
  • Import your Git repository

Configure New Project

On the configuration page, you need to set the following options:

  • Framework Preset: Select Next.js
  • Build Command: Use the default npm run build (or yarn build if using Yarn)
  • Output Directory: Use the default .next
  • Install Command: Use the default npm install (or yarn install if using Yarn)

If you're unsure about a setting, you can keep the default value. Vercel typically detects the correct configuration automatically.

Configure Environment Variables

On the configuration page, find the "Environment Variables" section

  • Add all necessary environment variables, for example:

    DATABASE_URL="your_database_URL"
    BETTER_AUTH_SECRET="your_better_auth_secret_key"
    RESEND_API_KEY="your_resend_api_key"
  • Make sure to add all necessary environment variables for running the project

  • Make sure the environment variables are set for the production environment

Deploy the Project

Click the "Deploy" button to start the deployment process. Vercel will automatically build and deploy your project.

Update Environment Variables

If you want to add or update environment variables after deploying the project, you can do it in the Project Settings > Environment Variables, and then redeploy the project.

Vercel Environment Variables

Automatic Deployments

Vercel provides automatic deployment functionality when you:

  • Push code to the main branch
  • Create a new Pull Request
  • Push to a branch with preview deployments enabled

Each Pull Request gets a unique preview URL, allowing you to test changes before merging to production.

Custom Domain

If you want to add a custom domain to your project:

  1. Go to your project settings in the Vercel console
  2. Navigate to the "Domains" section
  3. Add your custom domain
  4. Follow the DNS configuration instructions

Troubleshooting Common Issues

Build Failures

If the build process fails:

  • Check the build logs for detailed error information
  • Ensure all dependencies are correctly installed
  • Verify that environment variables are properly configured

Application Functions Incorrectly

  • Confirm all environment variables are set correctly
  • Check if the database connection is working properly
  • Verify that API keys for third-party services are valid
  • Check the logs for any errors or messages that can help you diagnose the issue

Next Steps

Now that you understand how to deploy your MkSaaS website to Vercel, explore these related topics:

Table of Contents