---
title: How to alias a preview deployment using the CLI
description: Learn how to automatically alias a Vercel preview deployment.
url: /kb/guide/how-to-alias-a-preview-deployment-using-the-cli
canonical_url: "https://vercel.com/kb/guide/how-to-alias-a-preview-deployment-using-the-cli"
published: 2025-11-03
last_updated: 2025-11-10
authors: Lee Robinson
related:
  - /docs/cli/alias
  - /docs/cli/deploy
install_vercel_plugin: npx plugins add vercel/vercel-plugin
---
<!-- docsgraph:related -->
## Related pages

> **For AI agents:** Follow these links to understand how this page connects to the rest of the Vercel ecosystem. For the full cross-link map (inbound, outbound, prerequisites, and semantic neighbors), see the .graph.md link below.

- [Deploy from CLI](https://vercel.com/docs/projects/deploy-from-cli?from=related) — Set up and deploy a Vercel project using the CLI, from linking to production.
- [Deploying from CLI](https://vercel.com/docs/cli/deploying-from-cli?from=related) — Learn how to deploy your Vercel Projects from Vercel CLI using the vercel or vercel deploy commands.
- [Generated URLs](https://vercel.com/docs/deployments/generated-urls?from=related) — When you create a new deployment, Vercel will automatically generate a unique URL which you can use to access that parti
- [Assign an Alias](https://vercel.com/docs/rest-api/aliases/assign-an-alias?from=related)
- [Deployments](https://vercel.com/docs/deployments?from=related) — Learn how to create and manage deployments on Vercel.
- [Can you deploy based on tags/releases on Vercel?](https://vercel.com/kb/guide/can-you-deploy-based-on-tags-releases-on-vercel?from=related) — Learn how to deploy based on tags/releases on Vercel.
- [How can I use GitLab Pipelines with Vercel?](https://vercel.com/kb/guide/how-can-i-use-gitlab-pipelines-with-vercel?from=related) — Learn how to use GitLab Pipelines to deploy to Vercel including support for self-managed GitLab.
- [How can I use CircleCI with Vercel?](https://vercel.com/kb/guide/how-can-i-use-circleci-with-vercel?from=related) — Learn how to use CircleCI to deploy to Vercel with custom CI/CD.
- [How can I use Bitbucket Pipelines with Vercel?](https://vercel.com/kb/guide/how-can-i-use-bitbucket-pipelines-with-vercel?from=related) — Learn how to use Bitbucket Pipelines to deploy to Vercel including support for Bitbucket Data Center.
- [How do I resolve alias related errors on Vercel?](https://vercel.com/kb/guide/how-to-resolve-alias-errors-on-vercel?from=related) — Information on resolving alias related errors on Vercel.

Full cross-link map for this page: [/kb/guide/how-to-alias-a-preview-deployment-using-the-cli.graph.md](/kb/guide/how-to-alias-a-preview-deployment-using-the-cli.graph.md)
<!-- /docsgraph:related -->


You can use Vercel CLI to create Preview Deployments and can also use the Vercel CLI to alias a URL to that deployment. Each preview deployment has a unique URL. The latest Preview Deployment is automatically aliased to a URL, ensuring you'll have a stable URL pointing to the last Preview Deployment.

This covers adding another URL to the Deployment using the [alias command](https://vercel.com/docs/cli/alias). In this example we use the Vercel CLI to do a deployment using the `vercel deploy` command. A successful deployment writes the deployed URL to the [Standard Output](https://vercel.com/docs/cli/deploy#standard-output-usage) so you can use it in later commands.

As an example:

```bash
url="$(vercel deploy)"
vercel alias set "$url" your-alias.app
```

## Example with GitHub Actions

In [this article](https://vercel.com/guides/how-can-i-use-github-actions-with-vercel) we cover how to deploy using GitHub Actions. We can expand that example and alter the last couple of lines to do that auto-aliasing.

To set this Action up, please refer back to the [original article](https://vercel.com/guides/how-can-i-use-github-actions-with-vercel). Then change the last lines as below:

```text
name: Vercel Preview Deployment
env:
  VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
  VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
on:
  push:
    branches-ignore:
      - main
jobs:
  Deploy-Preview:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Install Vercel CLI
        run: npm install --global vercel@latest
      - name: Pull Vercel Environment Information
        run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
      - name: Build Project Artifacts
        run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
      - name: Deploy Project Artifacts to Vercel
        run: |
          url="$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }})"
          vercel alias --token=${{ secrets.VERCEL_TOKEN }} set "$url" your-alias.app
```