---
title: Preview Environments
description: Configure preview environments for your Headless Platform sites.
url: https://developers.wpengine.com/docs/headless-platform/platform-guides/preview-environments/
image: https://developers.wpengine.com/og/docs/headless-platform/platform-guides/preview-environments.png
---

# Preview Environments

In this guide, you’ll learn how to configure preview environments for your Headless Platform sites.

## What are preview environments?

To make your Headless Platform workflow easier, you can now dynamically create new environments to test your changes when you open a pull request (PR), without having to go through all the configuration steps in the User Portal.

If you decide to turn this feature on, every PR opened against the ‘source branch’ (the branch linked to your Headless Platform environment) will automatically create a preview environment - based on the code of the branch that is looking to merge into your source branch in the PR. Closing or merging the PR will shut the environment down.

This feature is available for all supported repository hosting service provider (GitHub, GitLab or Bitbucket).

## Enable the ‘preview environments’ feature

This feature is enabled through a per-environment setting. Enable this setting by clicking on your Environment Details page’s left-hand submenu `Settings` item, and toggling on the `Preview Environments` setting:

![Settings page of Headless Platform Environment](https://developers.wpengine.com/_astro/open-settings-from-submenu.BYRxbTtV_24cM4z.webp)

Once you enable this feature via the toggle, every PR to the source branch for the environment will create a new preview environment automatically:

![Preview Environment Settings Toggle](https://developers.wpengine.com/_astro/toggle.aOiHwUPK_dC7s5.webp)

## Create a preview environment

Once the setting is turned on, you can test the process by opening a pull request to the environment’s source branch.

> **Note**
>
> To protect users from creating environments by unauthorized users, pull requests coming from forked repositories are ignored at the moment.

When the preview environment is created, a comment will be posted, from the WP Engine bot, on the pull request page - this comment will include the new environment’s URL, build logs, and other details (GitHub example shown here):

![GitHub comment for preview env](https://developers.wpengine.com/_astro/pr.BAVPG5a9_1fMj2z.webp)

In this comment you are provided with the status of the build, whether it succeeded or failed, and links directly to the build logs, the preview environment site, and access the preview environment’s details page (Portal).

![Preview environment details](https://developers.wpengine.com/_astro/successful-deployment.B4Fqz9zP_89HK9.webp)

You can also view all current preview environments for a given environment near the base of the Environment Details page, under the `Preview environments` tab:

![Open preview environments table](https://developers.wpengine.com/_astro/preview-env-table-disabled.C1fxlJUx_2bULzT.webp)

> **Note**
>
> Preview environments inherit both the environment variables and the link to WordPress from their ‘parent’ environment. You can modify the environment variables of a given preview environment on its details page in the User Portal.

## Delete a preview environment

The action of closing or merging the pull request will automatically shut the preview environment down.

You can also delete your preview environment through the User Portal - to do so, visit the preview environment details page and click the `Delete` button.

> **Note**
>
> Preview environments will automatically expire and be deleted after 90 days.

## Was this helpful?

Thanks for the feedback!

```json
{"@context":"https://schema.org","@graph":[{"@type":"WebSite","@id":"https://developers.wpengine.com/#website","name":"WP Engine Product Documentation","url":"https://developers.wpengine.com/","description":"Resources for developing, deploying, and scaling on WP Engine.","inLanguage":"en-US","keywords":["API documentation","product documentation","headless WordPress","managed WordPress hosting"],"publisher":{"@id":"https://wpengine.com/#organization"}}]}
```
