Migration Guide
Migrating to the v2 Node.js SDK
The Browserbase v2 Node.js SDK has been rewritten from the ground up and ships with a ton of new features and better support that we can’t wait for you to try. This guide is designed to help you maximize your experience with v2.
We hope this guide is useful to you; if you have any questions don’t hesitate to reach out to us at support@browserbase.com or by creating a new issue. We’ve written out specific guidelines on how to migrate each v1 method to v2 below. v2 also adds one-to-one mappings for every API endpoint, so you can incorporate new Browserbase features in your codebase with much less lift.
Breaking Changes
The v2 SDK is more flexible, easier to use, and has a more consistent API. It is also a lot more modular, meaning the majority of function calls have changed from browserbase.$thing$Do()
to browserbase.$thing.$do()
. For example:
Deleted Methods
load
, loadUrl
, and screenshot
have been fully removed in the v2 SDK. You can use the following example instead that encapsulates the same functionality using Playwright:
Updates to Common Workflows
Create Session
This is how you would create a session with the v1 SDK:
Now, you can create a session with the v2 SDK by calling the create
method on sessions
:
For more complex types, you can use the provided TypeScript types in the API reference:
Get Connect URL
In the v1 SDK, you could run browserbase.getConnectUrl()
to create a new session and retrieve its connect url, or browserbase.getConnectUrl({ sessionId: someSession.id })
to retrieve the connect url for an existing session.
In the v2 SDK, you can create a session and retrieve its connect url in a single call with bb.sessions.create()
. Getting the connect url for an existing session is no longer supported.
Complete Session
v1 allowed you to complete a session by calling browserbase.completeSession()
:
In the v2 SDK, completing a session is done by updating its status to REQUEST_RELEASE
:
Reference for other methods
These methods have been rewritten for modularity and flexibility. As mentioned above, the pattern here is that the method has been renamed from browserbase.$thing$Do()
to bb.$thing.$do()
.
List Sessions
Get Session
Get Session Recording
Get Session Downloads
Note: The parameter retryInterval
is no longer supported. You can configure retries with the following syntax on initialization:
Keep in mind, however, that this only affects the default retry behavior, which will only retry on 4xx/5xx errors. The remaining pattern still applies:
Get Debug Connection URLs
Get Session Logs
Was this page helpful?