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/platform/playwright.mdx
+48Lines changed: 48 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -181,6 +181,54 @@ export default {
181
181
};
182
182
```
183
183
184
+
### Storage state
185
+
186
+
Playwright supports [storage state](https://playwright.dev/docs/api/class-browsercontext#browsercontext-storage-state) to obtain and persist cookies and other storage data.
187
+
188
+
Here's an example that uses storage state to persist cookies and other storage data in [KV](https://developers.cloudflare.com/kv):
189
+
190
+
<WranglerConfig>
191
+
192
+
```jsonc
193
+
{
194
+
"name":"storage-state-examples",
195
+
"main":"src/index.ts",
196
+
"compatibility_flags": ["nodejs_compat"],
197
+
"compatibility_date":"2025-09-17",
198
+
"browser": {
199
+
"binding":"MYBROWSER"
200
+
},
201
+
"kv_namespaces": [
202
+
{
203
+
"binding":"KV",
204
+
"id":"<YOUR-KV-NAMESPACE-ID>"
205
+
}
206
+
]
207
+
}
208
+
```
209
+
210
+
</WranglerConfig>
211
+
212
+
```ts title="src/index.ts"
213
+
// gets persisted storage state from KV or undefined if it doesn't exist
If users omit the `browser.close()` statement, the browser instance will stay open, ready to be connected to again and [re-used](/browser-rendering/workers-bindings/reuse-sessions/) but it will, by default, close automatically after 1 minute of inactivity. Users can optionally extend this idle time up to 10 minutes, by using the `keep_alive` option, set in milliseconds:
0 commit comments