Smoother automation with Browserbase Contexts
Contexts persist data across browser sessions.

1
npx create-browser-app --template context
1
uvx create-browser-app --template context
Create contexts with Browserbase
This template shows how to use Browserbase contexts to persist authentication across sessions. Instead of logging in every time, cookies and tokens are saved once and reused, making flows faster and more reliable. It's perfect for automating logins, accessing gated content, and keeping state consistent across retries or scheduled jobs.
Steps
- Create a Browserbase session and log in to a target site using Stagehand.
- Save the session's context (including cookies, storage, and tokens).
- Reuse the stored context in new sessions without needing to log in again.
- Run subsequent scripts faster with authentication and state already in place.