Overview
A viewport defines the visible area of a web page in a browser window. While setting a custom viewport is optional in Browserbase, it can be helpful for specific use cases — such as visual testing, screenshot generation, or automations that rely on precise layout behavior.Configuring the Viewport
Use theviewport field when creating a session to specify the desired width and height. Below are examples in both Node.js and Python SDKs.
- Node.js
- Python
Browser sessions with basic stealth allow for any custom viewport dimensions. Browser sessions with advanced stealth require a viewport configuration that matches the
os you specify; see our advanced stealth customization guide for more details.Setting the Viewport with Puppeteer
If you are using Puppeteer as your browser automation framework, Puppeteer applies an800 x 600 default viewport by default. To customize these dimensions, you will also need to set the defaultViewport to null as shown below.