This directory contains examples of how to use BrowserState with different storage providers and browser automation tools.
examples/
├── local/ # Examples using local storage
│ ├── playright-test.ts # Playwright example with local storage
│ └── puppeteer-test.ts # Puppeteer example with local storage
├── google/ # Examples using Google Cloud Storage
│ └── gcs-example.ts # Playwright example with GCS
├── s3/ # Examples using AWS S3 Storage
│ └── s3-example.ts # Example with S3 (to be added)
└── README.md # This file
Before running these examples, you'll need to install the required dependencies:
# Core dependencies
npm install browserstate playwright puppeteer
# For Google Cloud Storage examples
npm install @google-cloud/storage
# For AWS S3 examples
npm install @aws-sdk/client-s3 @aws-sdk/lib-storageLocal storage examples can be run without any additional configuration:
# Using Playwright
npx ts-node examples/local/playright-test.ts
# Using Puppeteer
npx ts-node examples/local/puppeteer-test.tsTo run the Google Cloud Storage examples, you'll need:
- A Google Cloud project
- A GCS bucket
- A service account with Storage Admin permissions
- A downloaded service account key file
- Go to the Google Cloud Console
- Select or create a project
- Go to "IAM & Admin" > "Service Accounts"
- Create a new service account or use an existing one
- Assign the "Storage Admin" role (or a more specific role with necessary permissions)
- Create a key for the service account (JSON format)
- Download the key file and keep it secure
- Update the
keyFilenamepath in the example to point to your key file
# Run the GCS example
npx ts-node examples/google/gcs-example.tsTo run the AWS S3 examples, you'll need:
- An AWS account
- An S3 bucket
- AWS credentials (access key and secret key) with S3 permissions
- Go to the AWS Management Console
- Go to "IAM" > "Users" > Select or create a user
- Under "Security credentials", create an access key
- Save the access key ID and secret access key
- Update the example with your credentials
For each storage provider:
- Only LocalStorage has been extensively tested and is confirmed working
- S3Storage and GCSStorage implementations need additional testing
If you encounter any issues with the cloud storage providers, please create a GitHub issue with details about the problem.