Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Playwright’s browser.bind(title, { metadata }) method when you need descriptive application data attached to a browser server. The method names the bound server and associates your own key-value object with it. It does not turn metadata into page data, replace browser-context isolation, or describe an already-running browser connection. The API is documented as added in Playwright v1.59, so check the current Playwright API reference before deploying code.

What “browser session metadata” means in Playwright

Playwright has several layers that are easy to conflate:

  • Browser server: the Playwright-managed process or endpoint to which clients bind or connect.
  • Browser context: an isolated browsing environment. Contexts do not share cookies or cache.
  • Page: a tab within a context.
  • Attached browser: an existing browser reached through the Playwright protocol or, for Chromium, the Chrome DevTools Protocol (CDP).

Browser.bind addresses the first layer. Its metadata describes the bound browser server; it is not documented as arbitrary page or context metadata. Playwright also does not document automatic persistence across restarts or exposure of these values to websites. If you need data inside a page, pass it explicitly through your application or page APIs.

Attach metadata with browser.bind

Minimal Node.js shape

The documented signature is represented by this compact example:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await browser.bind("checkout-worker", {
  metadata: {
    runId: "run-123",
    owner: "checkout-tests"
  }
});

checkout-worker is the browser-server title. The metadata object contains application-defined descriptive fields. Playwright does not prescribe names such as runId or owner; choose a stable schema that your logs and orchestration system understand.

A complete illustrative flow

The following shows where the call belongs in a Node.js program. The browser creation and cleanup details can vary by your Playwright version and deployment, so treat the bind call as the important API operation and verify the surrounding setup against the current documentation.

import { chromium } from "playwright";

const browser = await chromium.launch();

await browser.bind("checkout-worker", {
  metadata: {
    runId: "run-123",
    owner: "checkout-tests",
    environment: "staging"
  }
});

const context = await browser.newContext();
const page = await context.newPage();
await page.goto("https://example.com");

console.log(await page.title());
await browser.close();

Keep identifiers concise and serializable. Include only information that helps operators identify the server, such as a job ID, tenant reference, environment, or owning service. Do not assume that a page, another Playwright client, or a restarted process will automatically receive the object.

Choose the right mechanism for your goal

Need Approach What it actually provides
Name and associate application data with a browser server Browser.bind(title, { metadata }) Server-level metadata; documented as added in v1.59.
Keep users or test runs isolated Separate BrowserContext instances Contexts do not share cookies or cache.
Connect to a remote Playwright browser Playwright protocol connect Higher fidelity than CDP according to Playwright’s API documentation.
Connect to an existing Chromium debugging endpoint connectOverCDP or CLI attach --cdp Chromium-only for the Playwright API and lower fidelity than Playwright-protocol connection.
Let an agent use an existing Chrome profile Chrome DevTools agent connection Access to the active browser session and data surfaced through browser APIs.

Metadata labels a server; contexts provide isolation; connection APIs provide control. Combining them is normal: bind a server with job metadata, create one context per isolated run, and connect through the protocol appropriate for your browser.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Metadata design that remains useful in production

Use stable, searchable keys

  • runId or jobId for the orchestrator’s unique execution identifier.
  • owner for the team or service responsible for the run.
  • environment for values such as staging or production.
  • purpose for a short description such as checkout-tests.

Keep the values safe for logs. Avoid passwords, session cookies, access tokens, personal data, or complete URLs containing secrets. Metadata is descriptive, not a secret-management channel.

Do not use metadata as an isolation substitute

Giving two jobs different runId values does not prevent them from sharing cookies or cache. Create separate contexts when state separation matters:

const workerA = await browser.newContext();
const workerB = await browser.newContext();

// workerA and workerB have separate cookies and cache.
const pageA = await workerA.newPage();
const pageB = await workerB.newPage();

Attaching to an existing browser

Playwright protocol versus CDP

If the browser is already running, use a connection operation rather than treating bind as an attachment command. Playwright’s protocol connect is the higher-fidelity option when a Playwright server endpoint is available.

connectOverCDP attaches through the Chrome DevTools Protocol. Playwright documents this method as attaching to an existing browser instance using CDP. The API supports Chromium-based browsers only and is lower fidelity than the Playwright protocol connection. A browser launched without Playwright’s curated arguments may also have functionality that does not work as expected when connected.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Playwright CLI attachment and lifecycle

The Playwright CLI can attach by browser channel, CDP endpoint, Playwright server endpoint, or browser extension. Give each attachment an explicit session name when several connections may coexist.

  • detach: ends the CLI attachment while leaving an externally running browser alone.
  • close: closes a browser that the CLI launched.

Using close against an externally managed browser can be a destructive lifecycle mistake. Decide who owns the process before selecting a command.

Security of personal-browser connections

A connection to a personal Chrome profile is an access grant, not just a debugging convenience. Chrome’s agent guidance states that a connected agent inherits access to the active session, including accounts, cookies, local storage, and other data exposed through browser APIs. Prefer a dedicated profile, least-privilege accounts, and a short-lived debugging endpoint for automation. Never attach an untrusted agent to a profile containing personal or production credentials.

Operational patterns and edge cases

Multiple workers

Use a unique server title for each independently managed browser server. If your scheduler can retry a job, include an attempt number in metadata rather than silently reusing a title that operators may interpret as the original process.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Restarts and persistence

The documented API describes metadata associated with the browser server; it does not establish persistence across process restarts. Reapply metadata whenever a new server is launched, and store the authoritative run record in your scheduler or logging system.

Logging

Write the same identifiers to your application logs when you launch, bind, connect, and close. This lets you correlate browser-server events with test results without assuming that metadata is visible inside pages.

Troubleshooting

“browser.bind is not a function”

Check the Playwright package version and the object on which you call the method. The documented Browser.bind addition is v1.59. An older package, a different object, or a wrapper that has not exposed the method will produce this symptom. Upgrade deliberately, then confirm the current API signature and release notes.

The metadata is missing from a page

That is expected if you assumed server metadata would become JavaScript page data. Pass the value explicitly through your own application channel, such as a test fixture, request header, or page initialization script, while keeping secrets out of the metadata object.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Two jobs are sharing login state

Metadata does not isolate storage. Create separate browser contexts and verify that each job receives its own context. Contexts are the boundary that prevents cookies and cache from being shared.

CDP connection behaves differently from a normal Playwright connection

Confirm that the target is Chromium and that the endpoint is reachable. CDP has lower fidelity than the Playwright protocol, so a feature that depends on Playwright’s full protocol may behave differently. When possible, expose and use a Playwright server endpoint instead.

Detaching stopped the wrong thing

Use detach for an externally running browser and reserve close for a browser launched by the CLI. Review process ownership before repeating the command.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance, reliability and cost considerations

Metadata itself is a small descriptive payload; the expensive operations are browser startup, navigation, network traffic, and page execution. Reuse a browser server when appropriate, but retain separate contexts for isolation. Bound the lifetime of contexts and pages so abandoned jobs do not retain resources.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For reliable automation, record the server title, run ID, connection method, browser type, and context ownership in logs. Treat browser endpoints as credentials: protect them with network controls and rotate or close them after the job. Because the API is version-sensitive, pin Playwright in CI and recheck the v1.59 API behavior when upgrading.

Or skip the browser setup

If your actual goal is a clean image or PDF of a web page rather than control of a Playwright session, ScreenshotNeo provides a single HTTP request. It accepts cookie and consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups and chat widgets before capture; each cleanup step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing result. Its MCP server includes take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients.

Start with the ScreenshotNeo API documentation for options such as full-page capture, CSS-selector element capture, device presets, retina scale, custom CSS and JavaScript, waits, request blocking, headers, cookies, geolocation, PDF settings, caching, signed links, asynchronous jobs and bulk capture.

One-call examples

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

There is a free allowance of 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 shots; every feature is on every plan. Create a free ScreenshotNeo account to try it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

Does Browser.bind attach metadata to a BrowserContext?

No. The documented metadata belongs to the bound browser server. Use separate contexts for cookie and cache isolation.

Can I use connectOverCDP with Firefox or WebKit?

Playwright documents connectOverCDP for Chromium-based browsers. Use a Playwright-protocol connection for other supported browser types when available.

Will metadata survive a browser restart?

The API documentation does not promise persistence. Apply the metadata again whenever you create a new browser server.

Should I attach an agent to my everyday Chrome profile?

Avoid it when possible. A connected agent can access the active profile’s accounts, cookies, local storage and other browser-exposed data; use a dedicated profile instead.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The Bottom Line

Use Browser.bind(title, { metadata }) for server-level labels, separate BrowserContext instances for state isolation, and the appropriate Playwright or CDP connection API when taking control of an existing browser.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.