Browser Profiles
Browser profiles persist cookies, localStorage, and fingerprint data across sessions. This lets you maintain login states and avoid re-authenticating on every run.
How Profiles Work
- Create a profile via the API or SDK
- Pass the
profileIdwhen creating a browser session - Set
profilePersist: trueto save changes when the session ends - On the next session with the same profile, all data is restored
Creating a Profile
import { ScrayleClient } from '@scrayle/sdk';
const client = new ScrayleClient();
const profile = await client.profiles.create('my-login-profile');
console.log(profile.profileId); // Use this ID in browser sessionsUsing a Profile
import { Playwright } from '@scrayle/sdk';
import { chromium } from 'playwright-core';
const { browserWSEndpoint } = await Playwright.connect({
profileId: 'prof_abc123',
profilePersist: true, // Save profile when session ends
});
const browser = await chromium.connectOverCDP(browserWSEndpoint);
const page = await browser.newPage();
await page.goto('https://example.com/dashboard');
// If previously logged in, the session is restored
await browser.close(); // Profile savedListing Profiles
const result = await client.profiles.list({
page: 1,
limit: 20,
name: 'my-', // Optional name filter
});
for (const profile of result.docs) {
console.log(profile.profileId, profile.name, profile.createdAt);
}Deleting a Profile
await client.profiles.delete('prof_abc123');Profile Data
Profiles store:
- Cookies (including HttpOnly)
- localStorage and sessionStorage
- IndexedDB data
- Browser fingerprint configuration
API Reference
| Method | Description |
|---|---|
profiles.create(name) | Create a new profile |
profiles.get(profileId) | Get profile details |
profiles.list(params?) | List all profiles (paginated) |
profiles.delete(profileId) | Delete a profile |