You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/browser-rendering/get-started/screenshots.mdx
+11-5Lines changed: 11 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,7 +41,13 @@ In your `browser-worker` directory, install Cloudflare’s [fork of Puppeteer](/
41
41
npm install @cloudflare/puppeteer --save-dev
42
42
```
43
43
44
-
## 3. Create a KV namespace
44
+
## 3. Enable Node.js compatibility
45
+
46
+
[Node.js compatibility](/workers/runtime-apis/nodejs/) is required for Puppeteer, and needs to be configured for your Workers project.
47
+
48
+
<Renderfile="nodejs_compat"product="workers" />
49
+
50
+
## 4. Create a KV namespace
45
51
46
52
Browser Rendering can be used with other developer products. You might need a [relational database](/d1/), an [R2 bucket](/r2/) to archive your crawled pages and assets, a [Durable Object](/durable-objects/) to keep your browser instance alive and share it with multiple requests, or [Queues](/queues/) to handle your jobs asynchronous.
## 4. Configure the `wrangler.toml / wrangler.json` file
65
+
## 5. Configure the `wrangler.toml / wrangler.json` file
60
66
61
67
Configure your `browser-worker` project's [`wrangler.toml / wrangler.json` file](/workers/wrangler/configuration/) by adding a browser [binding](/workers/runtime-apis/bindings/) and a [Node.js compatibility flag](/workers/configuration/compatibility-flags/#nodejs-compatibility-flag). Bindings allow your Workers to interact with resources on the Cloudflare developer platform. Your browser `binding` name is set by you, this guide uses the name `MYBROWSER`. Browser bindings allow for communication between a Worker and a headless browser which allows you to do actions such as taking a screenshot, generating a PDF and more.
@@ -165,15 +171,15 @@ If your Worker is running in production, it will store the screenshot to the pro
165
171
166
172
If the same `"url"` is requested again, it will use the cached version in KV instead, unless it expired.
167
173
168
-
## 6. Test
174
+
## 7. Test
169
175
170
176
Run [`npx wrangler dev --remote`](/workers/wrangler/commands/#dev) to test your Worker remotely before deploying to Cloudflare's global network. Local mode support does not exist for Browser Rendering so `--remote` is required.
171
177
172
178
To test taking your first screenshot, go to the following URL:
173
179
174
180
`<LOCAL_HOST_URL>/?url=https://example.com`
175
181
176
-
## 7. Deploy
182
+
## 8. Deploy
177
183
178
184
Run `npx wrangler deploy` to deploy your Worker to the Cloudflare global network.
0 commit comments