Skip to content

Commit 9bd5306

Browse files
committed
[Workers] Bold first-use terms and add cross-reference anchor links throughout Previews docs
1 parent 27bdd78 commit 9bd5306

2 files changed

Lines changed: 22 additions & 22 deletions

File tree

src/content/docs/workers/previews/api.mdx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ description: Understand the Previews data model and use the API to manage Previe
1010

1111
import { Details } from "~/components";
1212

13-
This guide walks you through the Workers Previews API from the ground up. It assumes you can make authenticated requests to the Cloudflare API and that you already have a production Worker deployed.
13+
This guide walks you through the Workers Previews API from the ground up. For a higher-level introduction to what Previews are and how to get started, refer to the [Previews overview](/workers/previews/). This page assumes you can make authenticated requests to the Cloudflare API and that you already have a production Worker deployed.
1414

1515
Every endpoint below lives under a common base path:
1616

@@ -68,7 +68,7 @@ Anywhere the API accepts a `{preview_id}` path parameter, you can pass any of th
6868

6969
### What a Preview contains vs. what a Deployment contains
7070

71-
The Previews API splits configuration into two layers: the **Preview layer** and the **Deployment layer**.
71+
The Previews API splits configuration into two layers: the **Preview layer** and the **Deployment layer**. Understanding this split is key to working with the API.
7272

7373
The **Preview layer** holds settings that apply across all of a Preview's Deployments: observability, log routing (`logpush`, `tail_consumers`), and organizational metadata (`tags`). These persist for the lifetime of the Preview regardless of how many Deployments you create.
7474

@@ -195,7 +195,7 @@ The Deployment object represents the Deployment layer. Here is its full shape:
195195

196196
## Preview Defaults
197197

198-
Your production Worker can store a property called `preview_defaults`. It is a template of starting values that Cloudflare applies whenever you create a new Preview or Deployment. It is not a standalone API resource -- you read and write it through the existing Worker endpoints (`PUT` or `PATCH` on `/workers/workers/{worker_id}`).
198+
Your production Worker can store a property called **`preview_defaults`**. It is a template of starting values that Cloudflare applies whenever you create a new Preview or Deployment. It is not a standalone API resource -- you read and write it through the existing Worker endpoints (`PUT` or `PATCH` on `/workers/workers/{worker_id}`). You can also configure these from the dashboard or your Wrangler configuration file -- refer to [Set up Previews](/workers/previews/#set-up-previews) for a walkthrough.
199199

200200
`preview_defaults` carries values for both layers:
201201

@@ -317,13 +317,13 @@ Previews and Deployments each receive automatically assigned URLs. The format de
317317
| Preview | `{slug}.{worker}.cloudflare.app` | `feature-auth.my-worker.cloudflare.app` |
318318
| Deployment | `{short_id}.{worker}.cloudflare.app` | `f498jo.my-worker.cloudflare.app` |
319319

320-
A Preview URL always points to the latest Deployment. A Deployment URL always points to that exact immutable Deployment.
320+
A **Preview URL** always points to the latest Deployment. A **Deployment URL** always points to that exact immutable Deployment. For a quick summary of both URL types, refer to [Preview URLs and Deployment URLs](/workers/previews/#preview-urls-and-deployment-urls).
321321

322-
These URLs appear in the read-only `urls` field on both the Preview and Deployment objects.
322+
These URLs appear in the read-only `urls` field on both the [Preview object](#preview-object) and [Deployment object](#deployment-object).
323323

324324
### Custom domains
325325

326-
You can route Previews through your own domain by enabling `previews_enabled` on a Worker custom domain:
326+
You can route Previews through your own domain by enabling `previews_enabled` on a Worker custom domain. For Wrangler configuration and dashboard instructions, refer to [Use a custom domain for Previews](/workers/previews/#use-a-custom-domain-for-previews).
327327

328328
```bash
329329
curl -X PUT \
@@ -359,7 +359,7 @@ Both `production_enabled` and `previews_enabled` are optional and default to `tr
359359

360360
### Set Preview Defaults
361361

362-
Use the existing Worker endpoints. Include `preview_defaults` in the body:
362+
Use the existing Worker endpoints. Include `preview_defaults` in the body. Refer to [Preview Defaults](#preview-defaults) for how these values merge with individual Preview and Deployment requests.
363363

364364
```txt
365365
PUT /workers/workers/{worker_id}
@@ -525,7 +525,7 @@ DELETE /{deployment_id}
525525

526526
### 1. Set Preview Defaults on your Worker
527527

528-
This is a one-time setup step. You are patching the parent Worker, not creating a new resource.
528+
This is a one-time setup step. You are patching the parent Worker, not creating a new resource. You can also do this from the dashboard or Wrangler -- refer to [Set up Previews](/workers/previews/#set-up-previews).
529529

530530
```bash
531531
curl -X PATCH \
@@ -557,7 +557,7 @@ curl -X POST \
557557
}'
558558
```
559559

560-
The response includes the Preview's `id`, `slug` (`feature-auth`), and `urls`. The `observability` setting comes from `preview_defaults` because you did not override it.
560+
The response includes the Preview's `id`, `slug` (`feature-auth`), and `urls`. The `observability` setting comes from `preview_defaults` because you did not override it. Refer to [How defaults merge](#how-defaults-merge) for details on this behavior.
561561

562562
### 3. Create a Preview Deployment
563563

src/content/docs/workers/previews/index.mdx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ import {
1818
InlineBadge,
1919
} from "~/components";
2020

21-
A Preview is an isolated copy of your Worker running on its own URL that you use to test changes before deploying to production. A Worker can have many Previews running at the same time, each isolated from each other. Each Preview runs with its own bindings, environment variables, and secrets, so your preview traffic never touches your production data.
21+
A **Preview** is an isolated copy of your Worker that runs on its own URL, so you can test changes before deploying to production. A Worker can have many Previews running at the same time, each isolated from each other. Each Preview runs with its own [bindings](/workers/runtime-apis/bindings/), environment variables, and secrets, so your preview traffic never touches your production data.
2222

23-
Previews are created automatically when you push to any branch other than your tracked branch (usually `main`), or manually with `wrangler preview`.
23+
Previews are created automatically when you push to any branch other than your tracked branch (usually `main`), or manually with `wrangler preview`. For a deeper look at how Previews and their Deployments are structured, refer to [Previews API](/workers/previews/api/).
2424

2525
## Quick start
2626

@@ -42,17 +42,17 @@ git checkout -b new-feature
4242
wrangler preview
4343
```
4444

45-
Wrangler builds your code locally and deploys it as a Preview. It prints a **Preview URL** and a **Deployment URL** to your terminal.
45+
Wrangler builds your code locally and deploys it as a Preview. It prints a **[Preview URL](#preview-urls-and-deployment-urls)** and a **[Deployment URL](#preview-urls-and-deployment-urls)** to your terminal.
4646

4747
---
4848

4949
## Set up Previews
5050

51-
Previews use their own bindings, environment variables, and secrets -- separate from your production Worker settings. Before creating your first Preview, you need to configure what resources and environment variables Previews should use.
51+
Previews use their own bindings, environment variables, and secrets -- separate from your production Worker settings. Before creating your first Preview, you need to configure what resources and environment variables Previews should use. These are called **[Preview Defaults](/workers/previews/api/#preview-defaults)** -- a template of starting values that every new Preview inherits automatically.
5252

5353
### From the dashboard
5454

55-
Go to your Worker > **Settings**, and you will see a banner for setting up your default Preview settings. This walks you through the bindings, environment variables, and observability settings you want every Preview to start with. This is the fastest way to get your whole team set up -- anyone who creates a Preview (manually or by pushing a branch) gets the same configuration without needing to specify it themselves.
55+
Go to your Worker > **Settings**, and you will see a banner for setting up your default Preview settings. This walks you through the bindings, environment variables, and [observability](#observability-and-logging) settings you want every Preview to start with. This is the fastest way to get your whole team set up -- anyone who creates a Preview (manually or by pushing a branch) gets the same configuration without needing to specify it themselves.
5656

5757
### From code
5858

@@ -86,7 +86,7 @@ When you configure settings in both the dashboard and the Wrangler configuration
8686

8787
## Deploy a Preview
8888

89-
You can deploy a Preview automatically every time you push to a branch using Workers Builds, or manually from the command line with `wrangler preview`.
89+
You can deploy a Preview automatically every time you push to a branch using [Workers Builds](/workers/ci-cd/builds/), or manually from the command line with `wrangler preview`.
9090

9191
### Automate with Workers Builds
9292

@@ -98,12 +98,12 @@ Connect a GitHub or GitLab repository, and Cloudflare deploys a Preview for you
9898

9999
When you push to `main`, Cloudflare builds and deploys your Worker to production using your top-level Wrangler configuration -- your production bindings, environment variables, and secrets. When you push to any other branch, Cloudflare deploys a Preview using your Preview settings instead.
100100

101-
The first push to a branch creates a new Preview. Each subsequent push creates a new deployment within that Preview -- an immutable snapshot of your code at that point. This means you can always go back and inspect or compare any previous deployment, even after pushing new changes.
101+
The first push to a branch creates a new Preview. Each subsequent push creates a new **[Preview Deployment](/workers/previews/api/#preview-deployment)** within that Preview -- an immutable snapshot of your code at that point. This means you can always go back and inspect or compare any previous deployment, even after pushing new changes.
102102

103103
A bot comments on your pull request with:
104104

105-
- A link to the **Preview URL** (which always serves the latest deployment)
106-
- A **Deployment URL** (which points to that exact snapshot)
105+
- A link to the **[Preview URL](#preview-urls-and-deployment-urls)** (which always serves the latest deployment)
106+
- A **[Deployment URL](#preview-urls-and-deployment-urls)** (which points to that exact snapshot)
107107
- A link to the build logs
108108

109109
### Deploy manually with Wrangler
@@ -128,7 +128,7 @@ Use this for ad-hoc testing, external CI/CD pipelines, or when you are not using
128128

129129
## Preview URLs and Deployment URLs
130130

131-
When you deploy a Preview, Cloudflare generates two URLs:
131+
When you deploy a Preview, Cloudflare generates two URLs. For the full URL patterns across `workers.dev`, `cloudflare.app`, and custom domains, refer to [URL structure](/workers/previews/api/#url-structure).
132132

133133
- **Preview URL** -- always serves the latest deployment. When you push new code, the Preview URL points to the new deployment automatically. Share this with teammates when you want them to always see your latest changes.
134134

@@ -165,7 +165,7 @@ preview_urls = true
165165

166166
## Use a custom domain for Previews
167167

168-
You can serve Previews from your own custom domain instead of (or in addition to) `workers.dev`. When you enable Previews on a custom domain, Cloudflare creates a wildcard DNS record and adds a wildcard SAN to the domain's certificate to cover all Preview subdomains.
168+
You can serve Previews from your own **custom domain** instead of (or in addition to) `workers.dev`. When you enable Previews on a custom domain, Cloudflare creates a wildcard DNS record and adds a wildcard SAN to the domain's certificate to cover all Preview subdomains. For more details, refer to [Custom domains](/workers/previews/api/#custom-domains).
169169

170170
| URL type | Example |
171171
| ---------- | ----------------------------------- |
@@ -225,13 +225,13 @@ Each Preview runs its own observability and logging settings, independent of you
225225
- Enable [Logpush](/workers/observability/logpush/) to send a Preview's logs to your own storage for debugging.
226226
- Attach [Tail Workers](/workers/observability/logs/tail-workers/) to a Preview to pipe its logs into a custom analysis pipeline.
227227

228-
Configure these in the dashboard under **Workers & Pages** > your Worker > **Settings** > **Preview Defaults**, and Cloudflare applies them to every Preview created for that Worker.
228+
Configure these in the dashboard under **Workers & Pages** > your Worker > **Settings** > **Preview Defaults**, and Cloudflare applies them to every Preview created for that Worker. For details on how observability settings are structured, refer to the [Preview object](/workers/previews/api/#preview-object).
229229

230230
---
231231

232232
## Limits and lifecycle
233233

234-
- Previews do not count against the account-level Worker limit (100 free / 500 paid). They have a separate limit: **1,000** for free plans, **10,000** for paid plans.
234+
- Previews do not count against the account-level Worker limit (100 free / 500 paid). They have a separate limit: **1,000** for Free plans, **10,000** for Paid plans.
235235
- If you hit the limit, creating a new Preview automatically deletes the least-recently-deployed existing Preview to make room.
236236
- Previews are automatically deleted after a TTL since their last deployment.
237237
- Previews cannot be addressed by user-managed triggers (routes, cron triggers, queues). They are reachable only through their auto-generated URLs and custom-domain wildcard URLs.

0 commit comments

Comments
 (0)