Playwright Browser

Configure remote Playwright browser sessions over a WebSocket endpoint.

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.

Terminal
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.

.env
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

nuxt.config.ts
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

ConcernBehavior
Endpoint resolutionViteHub reads browser.wsEndpoint or PLAYWRIGHT_WS_ENDPOINT.
Auth headersViteHub reads browser.headers or PLAYWRIGHT_HEADERS_JSON.
TimeoutViteHub reads browser.timeout or PLAYWRIGHT_CONNECT_TIMEOUT_MS.
TransportViteHub connects with playwright-core over the Playwright WebSocket protocol.
Native paritybrowser.native exposes the remote Playwright handles.
Choose Playwright when you already run your own browser infrastructure and want the thinnest possible ViteHub provider layer.