Skip to content

Commit fed7aaa

Browse files
authored
Browser rendering docs to include nodejs_compat
1 parent 5226db4 commit fed7aaa

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/content/docs/browser-rendering/get-started/screenshots.mdx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,13 @@ In your `browser-worker` directory, install Cloudflare’s [fork of Puppeteer](/
4141
npm install @cloudflare/puppeteer --save-dev
4242
```
4343

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+
<Render file="nodejs_compat" product="workers" />
49+
50+
## 4. Create a KV namespace
4551

4652
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.
4753

@@ -56,7 +62,7 @@ npx wrangler kv:namespace create BROWSER_KV_DEMO --preview
5662

5763
Take note of the IDs for the next step.
5864

59-
## 4. Configure the `wrangler.toml / wrangler.json` file
65+
## 5. Configure the `wrangler.toml / wrangler.json` file
6066

6167
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.
6268

@@ -78,7 +84,7 @@ kv_namespaces = [
7884

7985
</WranglerConfig>
8086

81-
## 5. Code
87+
## 6. Code
8288

8389
<Tabs> <TabItem label="JavaScript" icon="seti:javascript">
8490
Update `src/index.js` with your Worker code:
@@ -165,15 +171,15 @@ If your Worker is running in production, it will store the screenshot to the pro
165171

166172
If the same `"url"` is requested again, it will use the cached version in KV instead, unless it expired.
167173

168-
## 6. Test
174+
## 7. Test
169175

170176
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.
171177

172178
To test taking your first screenshot, go to the following URL:
173179

174180
`<LOCAL_HOST_URL>/?url=https://example.com`
175181

176-
## 7. Deploy
182+
## 8. Deploy
177183

178184
Run `npx wrangler deploy` to deploy your Worker to the Cloudflare global network.
179185

0 commit comments

Comments
 (0)