World map

 

BM: Baca dalam Bahasa Melayu

World C3: Release & Deploy

A preview for every PR

You will learn: how each pull request gets its own live link to try before merging.

Checked with GitHub Actions 2026-10 on 31 Oct 2026

The problem

A pull request changes 300 lines of CSS. The reviewer reads every line. Does the menu page still look right?

Pick one answer.

Watch

Tap each point on the timeline.

A preview environment: A short-lived copy of the site for one pull request, with its own link. A tasting plate, cleared when the PR closes. is a tasting plate for one pull request. Tap through its life.

Try it

npx wrangler preview uploads a preview of your Worker to Cloudflare. Here it runs on every pull request. Run it.

Pick an event. Press Run and watch the line.

A pull request builds and uploads its own preview.

What happened on GitHub

Workflow file .github/workflows/preview.yml

name: Preview
on:
pull_request:
permissions:
contents: read
jobs:
preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- run: npm ci
- run: npx wrangler preview --name "pr-$PR"
env:
PR: ${{ github.event.pull_request.number }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}

The line

Pull request · feature → main

Predict

Now a stranger opens a pull request from their fork. Will the preview deploy?

Pick one answer.

Check

Check it. Find the pull request whose preview fails, and read the real error.

Try the events. Find the one asked for.

What happened on GitHub

Workflow file .github/workflows/preview.yml

name: Preview
on:
pull_request:
permissions:
contents: read
jobs:
preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- run: npm ci
- run: npx wrangler preview --name "pr-$PR"
env:
PR: ${{ github.event.pull_request.number }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}

The line

Pull request · feature → main

Check

Preview habits: good, or needs work?

Swipe right for good, left for needs work. Or use the buttons.

1 / 4

Delete the preview when the pull request closes.

Delete the preview when the pull request closes.

You did it!

You can now give every pull request its own preview.

Go deeper (optional)

Worker Previews are in open beta. Each one gets a link that updates with every push. Clean up when the pull request closes.

bash
npx wrangler preview delete --name "pr-7" --skip-confirmation
Delete the preview named pr-7 without a question first.

Workers Builds can also post the link on the pull request. Real rep (optional): add this workflow to a test Worker repo.