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

vite-plugin-cli-browser-bridge

v0.2.0

Published

A Vite plugin that allows an AI coding assistant to run commands on browser pages

Readme

vite-plugin-cli-browser-bridge

A Vite plugin that creates a bridge between CLI tools and the browser, enabling command execution in the browser context from the command line. Ideal for AI assistants, automation tools, and testing frameworks.

Features

  • Execute JavaScript commands in the browser from the command line
  • Capture and return browser console logs and command results
  • Control browser tabs (open, close, reload) programmatically
  • Seamless integration with AI assistants and automation tools

Installation

npm install vite-plugin-cli-browser-bridge --save-dev

Setup

Add the plugin to your vite.config.js or vite.config.ts:

import { defineConfig } from "vite";
import vitePluginCliBrowserBridge from "vite-plugin-cli-browser-bridge";

export default defineConfig({
  plugins: [
    vitePluginCliBrowserBridge({
      port: 3333, // Optional: WebSocket server port (default: 3333)
      verbose: true, // Optional: Verbose console logs (default: false)
    }),
  ],
});

Note: This plugin only operates in development mode and is a no-op during production builds.

Usage

CLI Commands

Once your Vite server is running with the plugin enabled, you can use the CLI to interact with the browser:

# Execute JavaScript in the browser
npx cli-browser-bridge exec "window.document.title"

# Reload the browser
npx cli-browser-bridge reload

# Open a new browser tab
npx cli-browser-bridge open

# Close all browser tabs
npx cli-browser-bridge close

# Use verbose mode for verbose console output (useful for debugging)
npx cli-browser-bridge exec --verbose "window.document.title"

Programmatic Usage

You can also use the CLI programmatically in your Node.js scripts:

import { exec } from "child_process";

// Execute a command in the browser
exec(
  'npx cli-browser-bridge exec "window.document.title"',
  (error, stdout, stderr) => {
    if (error) {
      console.error(`Error: ${error.message}`);
      return;
    }
    console.log(`Result: ${stdout}`);
  }
);

API Reference

CLI Commands

| Command | Description | | ---------------- | --------------------------------------------------------------------- | | exec <command> | Execute JavaScript in the browser (output is automatically formatted) | | reload | Force the browser to reload | | open | Open the Vite development server in the default browser | | close | Close all open browser tabs |

CLI Options

| Option | Description | | --------------- | --------------------------------------- | | -p, --port | WebSocket server port (default: 3333) | | -v, --verbose | Verbose console output (default: false) |

Browser Functions

The plugin automatically injects these functions into the browser:

  • window.executeCommand(command): Execute JavaScript in the browser context

Use Cases

AI Assistants

Perfect for AI assistants that need to interact with web applications:

# AI can get information from the page
npx cli-browser-bridge exec "window.document.title"

# AI can modify the page
npx cli-browser-bridge exec "document.querySelector('h1').textContent = 'Updated by AI'"

How It Works

  1. The plugin injects a WebSocket client into your Vite application
  2. The WebSocket client connects to a local server (default port: 3333)
  3. CLI commands are sent to the same WebSocket server
  4. Commands are forwarded to the browser and executed
  5. Results are returned to the CLI

For AI Agents

If you're an AI agent or building tools for AI agents, see AGENT_HINTS.md for a concise list of commands and tips specifically designed for LLM usage.

Contributing

See CONTRIBUTING.md for information on how to develop, test, and contribute to this project.

License

MIT

Author

HexaField (but mostly AugmentCode code assistant)