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-iframe-picker

v0.0.2

Published

Vite plugin and SDK for cross-origin iframe element picking

Readme

vite-plugin-iframe-picker

A Vite plugin and SDK toolset for picking DOM elements inside a cross-origin iframe. Useful for building low-code editors, devtools, or visual inspectors.

Features

  • 🚀 Vite Plugin: Automatically injects the picker client script into the iframe site.
  • 🔌 Universal SDK: Pure JS class for controlling the picker from the parent site (React/Vanilla friendly).
  • 💚 Vue Composition API: Dedicated useElementPicker hook for Vue 3 users.
  • 🛡️ Cross-Origin Ready: Uses postMessage for secure communication.

Installation

npm install vite-plugin-iframe-picker

Setup

1. Configure the Iframe Site (Child)

Add the plugin to your vite.config.js in the project that will be loaded inside the iframe.

import { defineConfig } from 'vite'
import iframePicker from 'vite-plugin-iframe-picker'

export default defineConfig({
  plugins: [
    iframePicker() 
  ]
})

This will automatically inject the necessary client script during development and build.

2. Configure the Parent Site (Host)

Use the SDK to control the picking process.

Usage with Vue 3

<script setup>
import { ref } from 'vue'
import { useElementPicker } from 'vite-plugin-iframe-picker/vue'

const iframeRef = ref(null)
const { isPicking, start, stop } = useElementPicker({
  onPick: (data) => {
    console.log('Selected Element:', data)
  },
  onCancel: () => {
    console.log('Picking canceled')
  }
})

const startPicking = () => {
  if (iframeRef.value) {
    start({ iframeElement: iframeRef.value })
  }
}
</script>

<template>
  <button @click="startPicking" :disabled="isPicking">Pick Element</button>
  <button @click="stop" :disabled="!isPicking">Stop</button>
  
  <iframe ref="iframeRef" src="http://your-iframe-site.com"></iframe>
</template>

Usage with React / Vanilla JS

import { IframePickerClient } from 'vite-plugin-iframe-picker/parent'

const client = new IframePickerClient({
  onPick: (data) => console.log(data),
  onCancel: () => console.log('Canceled')
})

// Start listening for messages
client.listen()

// Start picking
function start() {
  const iframe = document.querySelector('iframe')
  client.start(iframe)
}

// Stop picking
function stop() {
  client.stop()
}

// Cleanup when component unmounts
// client.unlisten()

API Reference

PickerResult Object

{
  tagName: string;
  id: string;
  className: string;
  innerText: string;
  rect: { x, y, width, height }; // Bounding client rect
  selector: string; // CSS selector path
}

Ignoring Elements

To prevent an element inside the iframe from being pickable (e.g., your own overlays), add the data-picker-ignore attribute:

<div data-picker-ignore>
  This element cannot be picked.
</div>

License

MIT