Vercel is a popular platform for deploying web applications and websites with ease. It offers seamless integration with Git repositories, making it a favorite among developers who want to streamline their deployment process.
Vercel allows for automatic deployments on every branch push and merges onto the Production Branch of your GitHub, GitLab, Bitbucket and Azure DevOps Pipelines projects.
This article explores the steps involved in deploying a Git repository using Vercel, from setting up your Vercel account to configuring your deployment settings.
Prerequisites
Before we get into deploying your Git repository with Vercel, make sure you have the following prerequisites in place:
A Vercel Account: Sign up for a Vercel account if you haven't already. You can use your GitHub, GitLab, or Bitbucket account to log in.
A Git Repository: Ensure that your project is hosted in a Git repository, such as GitHub, GitLab, or Bitbucket.
Step 1: Installing the Vercel CLI
To get started, you will need the Vercel Command Line Interface (CLI). You can install it globally on your machine using npm or yarn:
npm install -g vercel
# OR
yarn global add vercel
Step 2: Logging into Vercel
Open your terminal and run the following command to log in to your Vercel account:
vercel login
This command will open a browser window prompting you to authenticate with your Vercel account.
Step 3: Creating a New Project
Navigate to your project's directory in the terminal and run the following command to create a new Vercel project:
vercel init
Follow the on-screen prompts to link your Git repository to the Vercel project. You will be asked to select the repository you want to deploy.
Setting up your GitHub, GitLab, or Bitbucket repository on Vercel is only a matter of clicking the "New Project" button on the top right of your dashboard and following the steps.
For Azure DevOps repositories, use the Vercel Deployment Extension
After clicking it, you'll be presented with a list of Git repositories that the Git account you've signed up with has write access to.
To select a different Git namespace or provider, you can use the dropdown list on the top left of the section.
A list of Git repositories your Git account has access to.
You can also:
Select a third-party Git repository by clicking on Import Third-Party Git Repository on the bottom of the section.
Select one of our pre-built templates from the section on the right.
After you've selected the Git repository or template you want to use for your new project, you'll be taken to a page where you can configure your project before it's deployed.
You can:
Customize the project's name
Select a Framework Preset
Select the root directory of your project
Configure Build Output Settings
Step 4: Deploying Your Git Repository
Now that your project is set up, you can deploy it to Vercel by selecting the Deploy button to initiate a deployment or by using the following command:
vercel
Vercel will start building and deploying your project. You can monitor the deployment progress in your terminal.
Step 6: Accessing Your Deployed Project
Once the deployment is complete, Vercel will provide you with a unique URL where your project is live. You can access your deployed project by opening this URL in your web browser.
Step 7: Custom Domains (Optional)
If you want to use a custom domain for your project, Vercel makes it easy. You can configure custom domains in the Vercel dashboard under the "Domains" section.
Conclusion
Deploying a Git repository with Vercel is a straightforward process that can save you time and effort in managing your web projects. By following the steps outlined in this guide, you can quickly get your web applications and websites up and running on Vercel's reliable hosting infrastructure. Whether you're deploying a personal blog or a complex web application, Vercel's integration with Git makes the deployment process smooth and efficient.
For more of this: please follow me on Twitter(X); twitter.com/EngrNath3