Skip to main content
A reviewer should not have to download a branch and set it up on their own machine just to see a change. And an agent that builds a user interface should show what it built, not only describe it. A preview environment solves both. You give each branch, pull request or agent session a sandbox running the app’s development server. It has its own HTTPS link that you can share, it updates as the code changes, and it sleeps when nobody is looking at it. Here is how it fits into a pull request’s life:
1

A sandbox that serves port 3000

2

Get the code

In your pipeline, this step is a git clone --branch of the pull request’s branch. To keep the example self-contained, we write a small Vite app instead. (Vite is a popular development server for web apps.)
3

Install and start the dev server

Install the app’s dependencies, then start the development server with keep: true, so it keeps running across sleep and wake. Vite only answers requests for hostnames it knows about, so we tell it the sandbox’s hostname through an environment variable:
4

Open the link

Anyone with the link now sees the running branch in their own browser, with live reloading. They do not need to download the code or set anything up.
5

Push a change: the preview updates

When new commits arrive, run git pull in the same sandbox. Vite notices the changed files, and any open page reloads by itself. Here we change the file directly to show the effect:

When the PR closes

When the pull request is merged or closed, find its sandbox by label and delete it:

In GitHub Actions

In practice, a CI workflow runs these steps for you. This GitHub Actions workflow runs a small script each time a pull request is opened, updated or closed, with your Fibre key stored as a secret:
.github/workflows/preview.yml
scripts/preview.mjs finds the pull request’s sandbox by its label and uses the calls from this page. When the pull request is opened, it creates the sandbox and posts the link as a comment. When new commits arrive, it pulls them. When the pull request is closed, it deletes the sandbox.

Good to know

A few things to keep in mind with previews:

Public URLs

How a sandbox’s public address works.

Snapshots

Start previews with dependencies already installed.