Connect to a remote browser or launch a new local browser.
Page
, Browser
, or BrowserContext
objectbrowserPid
chromium
) or a provided executablePath
:
chromium
-based browsers in executablePath
, including Brave, patchright chromium, rebrowser, Edge, and more. See examples/browser/stealth.ts
for more. We do not support Firefox or Safari at the moment.
~/.config/browsernode/profiles/default
. You can open
this
profile
and log into everything you need your agent to have access to, and it will
persist over time.Page
, BrowserContext
, Browser
, and/or playwright
API object to BrowserSession(...)
:
page
directly to Agent(...)
as a shortcut.
--remote-debugging-port
:
Agent(sensitiveData={'https://auth.example.com': {x_key: value}})
for any secrets, and restrict the browser with BrowserSession(allowedDomains=['https://*.example.com'])
.keepAlive=true
If you want to use a single BrowserSession
with more than one agent:
BrowserSession
starts when the browser is launched/connected, and ends when the browser process exits/disconnects. A session internally manages a single live playwright browser context, and is normally auto-closed by the agent when its task is complete (if the agent started the session itself). If you pass an existing BrowserSession
into an Agent, or if you set BrowserSession(keepAlive=True)
, the session will not be closed and can be re-used between agents.
Browsernode provides a number of ways to re-use profiles, sessions, and other configuration across multiple agents.
userDataDir
in new BrowserSession
sBrowserSession
without closing itBrowserSession
s using the same userDataDir
BrowserSession
s using the same storageState
BrowserSession
, working in different tabsBrowserSession
, working in the same tabuserDataDir
sequentially.
Make sure to never mix different browser versions orexecutablePath
s with the sameuserDataDir
. Once run with a newer browser version, some migrations are applied to the dir and older browsers wont be able to read it.
BrowserSession
and avoid having to relaunch chrome.
Each agent will start off looking at the same tab the last agent ended off on.
BrowserProfile
object.
The recommended way to re-use cookies and localStorage state between separate parallel sessions is to use the storageState
option.
SingletonLock
file in the profile directoryuserDataDir
.
If you see errors like Failed to parse Extensions
when launching, you’re likely attempting to run an older browser with an incompatible userDataDir
that’s already been migrated to a newer Chrome version.
Playwright ships a version of chromium that’s newer than the default stable Google Chrome release channel, so this can happen if you try to use
a profile created by the default playwright chromium (e.g. userDataDir='~/.config/browsernode/profiles/default'
) with an older
local browser like executablePath='/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
.