---
title: "Preview environments"
description: "Give the Verification Agent a running copy of each change, with the login it needs to test it."
canonical: "https://baz.ai/docs/integrations/preview-environments"
---

# Preview environments

Give the Verification Agent a running copy of each change, with the login it needs to test it.

A preview environment is a deployed copy of your app for a single pull request, such as a Vercel preview. When Baz can open it, the Verification Agent loads the app in a browser, checks each requirement from the ticket, takes screenshots, and compares them with your Figma designs. Without one, verification falls back to code, ticket and design alignment.

## How Baz finds the preview URL

Your CI or deploy bot posts the preview URL on the pull request. Baz picks it up, signs in to the preview with the environment you configured, and runs the Verification Agent. You get a spec review report on the pull request, with screenshots of each requirement.

This happens automatically the first time a preview URL appears, if no spec review has run on that pull request yet. Baz recognizes these comments:

- A comment containing `Preview environment is ready` followed by the URL (recommended for your own CI)
- The Vercel bot's comment with a **Preview** link
- A table row such as `| Preview | https://... |`
- `Please open this link: https://...`

```md title="Comment from your CI"
### Preview environment is ready
https://pr-1234.preview.example.com
```

You can also start a run by hand with a comment that includes the URL. A URL in the command takes priority over earlier comments.

```text title="PR comment"
Baz spec review https://pr-4567.preview.example.com
```

The URL must be reachable from the internet. See [PR commands](/docs/reference/pr-commands) for the other ways to trigger a spec review.

## Add an environment

<Steps>
  <Step title="Open the integration">
    Go to **Settings → Integrations**, select **Preview Environment**, then **Preview Environment**, and select **Configure**.
  </Step>
  <Step title="Name it">
    Enter a **Name**, for example `Staging` or `Marketing site`.
  </Step>
  <Step title="Set URL patterns">
    Under **URL patterns**, add the hosts this environment serves, such as `app.example.com` or `*.vercel.app`, without a scheme, port or path. Leave it empty to make this the default environment.
  </Step>
  <Step title="Choose how Baz signs in">
    Pick a tab and fill in its fields, then select **Connect**.
  </Step>
</Steps>

Use **User & password** when the app has a login form or basic auth. Use **OAuth token** when the app reads an access token from `sessionStorage`: enter the **Token URL**, **Client ID**, **Refresh token**, and **Session storage key**, and Baz gets a fresh token before each session. Use **No login required** for a public site.

## Several apps

Add one environment per app. For each preview URL Baz picks an environment in this order:

1. Environments scoped to the pull request's repository, using **Applies to the following repository paths:** on the environment card.
2. An exact host match.
3. The longest matching wildcard, so `*.app.example.com` beats `*.example.com`.
4. The environment with no URL patterns, shown as **Default for all preview URLs**.

## Related

<CardGroup cols={2}>
  <Card title="Verification Agent" href="/docs/agents/deploy/verification-agent" icon="check-check">
    What the agent checks in the running app.
  </Card>
  <Card title="Figma" href="/docs/integrations/design-and-docs/figma" icon="figma">
    Add designs to compare against.
  </Card>
</CardGroup>
