Playwright Browser
The Playwright provider connects to a remote Playwright server over WebSocket. Use it when you want ViteHub's capability-based browser API without coupling your app to Browserbase or Cloudflare-specific browser infrastructure.
Before you start
Install playwright-core alongside @vitehub/browser.
pnpm add https://pkg.pr.new/vite-hub/vitehub/@vitehub/browser@main playwright-core
Set PLAYWRIGHT_WS_ENDPOINT in the runtime environment. Optionally set PLAYWRIGHT_HEADERS_JSON when the remote endpoint expects custom headers, and PLAYWRIGHT_CONNECT_TIMEOUT_MS when the default connect timeout is too short.
PLAYWRIGHT_WS_ENDPOINT=wss://browser.example.com/ws
PLAYWRIGHT_HEADERS_JSON={"Authorization":"Bearer your-token"}
PLAYWRIGHT_CONNECT_TIMEOUT_MS=30000
ViteHub reads these values from process.env. Your app or runtime must load them before startup.
Configure Playwright
export default defineNuxtConfig({
modules: ['@vitehub/browser/nuxt'],
browser: {
provider: 'playwright',
wsEndpoint: process.env.PLAYWRIGHT_WS_ENDPOINT,
},
})
Playwright-specific options
Set wsEndpoint, headers, or timeout in top-level browser config.
Keep endpoint credentials and transport settings in top-level browser config, not inside defineBrowser(). The definition file should stay portable.
What changes on Playwright
| Concern | Behavior |
|---|---|
| Endpoint resolution | ViteHub reads browser.wsEndpoint or PLAYWRIGHT_WS_ENDPOINT. |
| Auth headers | ViteHub reads browser.headers or PLAYWRIGHT_HEADERS_JSON. |
| Timeout | ViteHub reads browser.timeout or PLAYWRIGHT_CONNECT_TIMEOUT_MS. |
| Transport | ViteHub connects with playwright-core over the Playwright WebSocket protocol. |
| Native parity | browser.native exposes the remote Playwright handles. |