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

stimulus-component-api

v0.0.12

Published

The stimulus-component-api allows the developer to mount Vue.JS- and React-Components.

Readme

Stimulus-Component-API

The stimulus-component-api allows the developer to mount Vue.JS- and React-Components.

The API's adaptors handle:

  1. State Synchronisation between Component-Props and Stimulus-Value-Api
  2. Mounting Components when a stimulus-target enters the dom.
  3. Destruction of the component when either the stimulus-target leaves the dom or the controller is destroyed.
  4. Communication Interface to call Controller-Actions from the component.

Installation

Add the Package to your package.json e.g. via npm i stimulus-compoment-api or yarn add stimulus-compoment-api

configuring the components

Add a component-defintion to the static components array.

Please note that stimulus-component-api does not ship with any vue or react code! You have to provide references to their factoryFunction and renderFunction.

import { createApp, h } from 'vue'
import { createRoot } from 'react-dom/client';
import { createElement } from 'react';

import HelloWorldVue from '../vue/HelloComponent'
import HelloWorldReact from '../react/HelloComponent'

import { useComponents } from "stimulus-component-api"

export default class extends Controller {

  static targets = [ "hellovue", "helloreact" ]

  static values = { message: String }

  static components = [{
    type: 'vue',
    component: HelloWorldVue,
    target: 'hellovue',
    factoryFunction: createApp,
    renderFunction: h,
  }, {
    type: 'react',
    component: HelloWorldReact,
    target: 'helloreact',
    factoryFunction: createRoot,
    renderFunction: createElement
  }]

  initialize() {
    useComponents(this)
  }
}

State

You want to use your controllers values in your component? No Problem!

Access to the message value of this controller is simple:

export default class extends Controller {
  static values = { message: String }
}

Vue and React will receive the values as props!

To bubble up any changes back to stimulus, your can use the conventional ways for change propagation:

Vue: this.$emit("message:update", "Changed Message Value")

React:

export default function HelloComponent({ message, onChange }) {
  render(
    <button
      onClick={() => onChange({ message: "Hello" })}
    >
      Say Hello
    </button>
}

Actions

You want to call controller code from within a component? No Problem!

To call the sendMessage action in this controller:

export default class extends Controller {
  sendMessage(message) {
    console.log(`The message is "${message}"`)
  }
}

All you have to do is using one of the following methods for your framework:

Vue 2: this.$emit("action", { name: "sendMessage", parameters: ["Hello from Vue"]})

Vue 3: ctx.emit("action", { name: "sendMessage", parameters: ["Hello from Vue"]})

In React:

export default function HelloComponent({ message, onAction }) {
  useEffect(() => {
    onAction({
      name: "sendMessage",
      parameters: ["Hello from React"],
    })
  }, [message])
  render(<p>{ message }</p>)
}

Registering plugins in Vue 3

Vue3 allows you to register plugins AFTER app creation. In case that's necessary, you can provide a callback that is executed after the component is created, but before it is mounted.

import { createApp, h } from 'vue'
import { coolPlugin } from 'cool-vue-plugin'

import { useComponents } from "stimulus-component-api"

import HelloWorldVue from '../vue/HelloComponent'

export default class extends Controller {
  static targets = [ "hellovue" ]

  static components = [{
    type: 'vue',
    component: HelloWorldVue,
    target: 'hellovue',
    factoryFunction: createApp,
    renderFunction: h,
    callbackFunction (app) {
      app.use(coolPlugin)
    }
  }]

  initialize() {
    useComponents(this)
  }
}