npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

browser-storage-exporter

v1.0.1

Published

Export browser storage states (cookies, localStorage) using Playwright

Readme

Browser Storage Exporter

A Node.js CLI tool to export browser storage states (cookies, localStorage, sessionStorage) using Playwright. This tool can connect to a running browser instance and extract authentication data for testing and development purposes.

Features

  • Export cookies and localStorage from running browser instances
  • Support for multiple browser contexts and pages
  • Configurable debug endpoint URL
  • Direct page navigation and export
  • JSON output format compatible with Playwright's storageState

Installation

npm install browser-storage-exporter

Or use directly with npx:

npx browser-storage-exporter

Configuration

Environment Variables

Create a .env file in your project root based on .env.example:

cp .env.example .env

Edit .env to configure your browser debug URL:

# Browser Debug Configuration
DEBUG_URL=http://localhost:52686/json/version

Common debug URLs:

  • http://localhost:52686/json/version (default)
  • http://localhost:9222/json/version (standard Chrome debug port)
  • http://localhost:9223/json/version (alternative port)

Usage

Basic Usage

# Connect to local browser using default/env debug URL
npx browser-storage-exporter

# Specify output directory
npx browser-storage-exporter -o ./exports

# Use custom debug URL
npx browser-storage-exporter -d http://localhost:9222/json/version

Advanced Usage

# Connect using WebSocket URL directly
npx browser-storage-exporter ws://localhost:9222/devtools/browser/your-browser-id

# Open specific page and export its storage
npx browser-storage-exporter https://example.com

# Combine options
npx browser-storage-exporter -o ./my-exports -d http://localhost:9222/json/version

Command Line Options

Options:
  -h, --help              Show help information
  -o, --output <dir>      Specify output directory (default: current directory)
  -d, --debug-url <url>   Browser debug endpoint URL (default: from .env or http://localhost:52686/json/version)

Configuration:
  Create a .env file based on .env.example to set default DEBUG_URL

Browser Setup

For Chrome/Chromium

Start Chrome with remote debugging enabled:

# macOS
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222

# Linux
google-chrome --remote-debugging-port=9222

# Windows
"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222

For Microsoft Edge

# Windows
"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" --remote-debugging-port=9222

Output Format

The tool generates a JSON file containing:

{
  "cookies": [
    {
      "name": "session_id",
      "value": "abc123",
      "domain": ".example.com",
      "path": "/",
      "expires": 1640995200,
      "httpOnly": true,
      "secure": true,
      "sameSite": "Lax"
    }
  ],
  "origins": [
    {
      "origin": "https://example.com",
      "localStorage": [
        {
          "name": "user_preferences",
          "value": "{\"theme\":\"dark\"}"
        }
      ]
    }
  ]
}

Using with Playwright

You can use the exported storage state with Playwright:

const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch();
  const context = await browser.newContext({
    storageState: './browser-auth-complete.json'
  });
  
  const page = await context.newPage();
  await page.goto('https://example.com');
  // You should now be logged in with the exported session
  
  await browser.close();
})();

Troubleshooting

Common Issues

  1. "No browser contexts found"

    • Make sure your browser is running with remote debugging enabled
    • Check that the debug URL is accessible (try opening it in a browser)
    • Verify the port number matches your browser's debug port
  2. "Error processing page"

    • Some pages may block script execution
    • Try refreshing the target page
    • Ensure the page has finished loading
  3. Connection refused

    • Verify the browser is running with --remote-debugging-port
    • Check if another application is using the debug port
    • Try a different port number

Debug URLs

You can verify your browser's debug endpoint by visiting:

  • http://localhost:9222/json/version (or your configured port)

This should return JSON with browser information including the WebSocket debug URL.

Development

# Clone the repository
git clone <repository-url>
cd browser-storage-exporter

# Install dependencies
npm install

# Run locally
node bin/cli.js --help

License

MIT

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.