A unified approach to browser session persistence across frameworks
The PersistentSessionsProtocol (PSP) creates a standardized approach for browser automation tools to save, share, and restore session data across different frameworks and machines. This protocol bridges the critical gap in browser automation by providing a framework-agnostic method for persisting state, significantly reducing authentication friction and improving testing reliability.
npm install @psp/core @psp/playwright
Works with Playwright, Selenium, Puppeteer, Skyvern, Stagehand, and other major automation tools.
Preserves cookies, localStorage, sessionStorage, and authentication tokens.
Support for local filesystem, Redis, database, and cloud storage backends.
Encryption for sensitive session data with configurable security levels.
Capture and reproduce user interactions across environments.
For server-based session management and real-time updates.
Optimized for use with AI agents and browser automation.
Efficient session capture and restoration with minimal overhead.
PSP includes a responsive dashboard for managing sessions across different frameworks, providing real-time updates and detailed analytics.
cd packages/ui
npm install
npm start
For development with mock data:
REACT_APP_USE_MOCK_API=true npm start
import { chromium } from 'playwright';
import { PlaywrightAdapter } from '@psp/playwright';
// Initialize Playwright
const browser = await chromium.launch();
const context = await browser.newContext();
const page = await context.newPage();
// Create PSP adapter and session
const adapter = new PlaywrightAdapter();
const session = await adapter.createSession(page, {
name: 'my-auth-session',
storage: 'local'
});
// Navigate and log in
await page.goto('https://example.com/login');
await page.fill('input[name="username"]', 'user');
await page.fill('input[name="password"]', 'pass');
await page.click('button[type="submit"]');
// Wait for login to complete
await page.waitForNavigation();
// Capture the authenticated session
await session.capture();
console.log(`Session saved with ID: ${session.getId()}`);
// Later, restore the session in a new browser
const newBrowser = await chromium.launch();
const newContext = await newBrowser.newContext();
const newPage = await newContext.newPage();
// Load the saved session
const savedSession = await adapter.loadSession(session.getId());
await savedSession.restore(newPage);
// Now the new page has the authenticated session
await newPage.goto('https://example.com/dashboard');
// Already logged in!
# Create a PSP session with Selenium
from psp.client import SeleniumAdapter
from selenium import webdriver
# Initialize driver
driver = webdriver.Chrome()
# Create adapter and session
adapter = SeleniumAdapter()
session = adapter.create_session(driver,
name="my-authentication-session",
storage="cloud" # or 'local', 'redis', etc.
)
# Log in to your application
driver.get("https://example.com/login")
driver.find_element_by_name("username").send_keys("user")
driver.find_element_by_name("password").send_keys("pass")
driver.find_element_by_xpath("//button[@type='submit']").click()
# Capture the authenticated session
session.capture()
# Later, restore the session
new_driver = webdriver.Chrome()
session.restore(new_driver)
# Now new_driver has the same authenticated session
const puppeteer = require('puppeteer');
const { PuppeteerAdapter } = require('@psp/puppeteer');
async function example() {
// Initialize Puppeteer
const browser = await puppeteer.launch();
const page = await browser.newPage();
// Create PSP adapter and session
const adapter = new PuppeteerAdapter();
const session = await adapter.createSession(page, {
name: 'my-auth-session',
storage: 'local'
});
// Navigate and log in
await page.goto('https://example.com/login');
await page.type('input[name="username"]', 'user');
await page.type('input[name="password"]', 'pass');
await page.click('button[type="submit"]');
// Wait for login to complete
await page.waitForNavigation();
// Capture the authenticated session
await session.capture();
console.log(`Session saved with ID: ${session.getId()}`);
// Later, restore the session in a new browser
const newBrowser = await puppeteer.launch();
const newPage = await newBrowser.newPage();
// Load the saved session
const savedSession = await adapter.loadSession(session.getId());
await savedSession.restore(newPage);
// Now the new page has the authenticated session
await newPage.goto('https://example.com/dashboard');
// Already logged in!
}
Complete guide to installing PSP and implementing your first session capture and restore.
View GuideDetailed documentation of the protocol architecture and data model.
View Protocol DocsUse PSP to log in once, then reuse the same authenticated session for all your subsequent tests. This dramatically speeds up test suites by eliminating the need to go through authentication flows for each test.
Capture a session with Playwright and restore it in Selenium or Puppeteer. This allows teams using different automation frameworks to share sessions without duplicating work.
Let AI agents maintain state between different browser automation sessions, providing continuity when building complex workflows that span multiple interactions.
For complex user journeys that involve many steps, save checkpoints along the way so you can quickly restore to any point in the process for debugging or continued development.
@psp/playwright
@psp/selenium
@psp/puppeteer
@psp/browser-use
@psp/computer-use
psp-skyvern
@psp/stagehand
@psp/cloudflare
@psp/lambda
(Coming Soon)PSP supports local storage options for development and testing:
@psp/core
For team environments and production use, PSP supports:
PSP employs a layered architecture with four main components:
This design ensures flexibility while maintaining compatibility across different frameworks. For more details, see the Protocol Specification.