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

vue3-mount

v0.6.5

Published

A lightweight api to dynamically mount Vue components.

Readme

Introduction

Vue3Mount is a lightweight api for dynamically mounting Vue components.

Features

  • Supports reactive props
  • Supports inject/provide api
  • Provides Custom directive for handling transition
  • Supports Options API

Getting started

1. Using NPM

Install

npm install vue3-mount
// or
pnpm add vue3-mount

Register

// app.ts
import Vue3Mount from 'vue3-mount'

const app = createApp(App)
app.use(Vue3Mount)

2. CDN

Install


<script src="https://unpkg.com/vue3-mount"></script>

Register

const {Mount: Vue3Mount} = window.Vue3Mount
const app = createApp(App)
app.use(Vue3Mount)

Usage

Define a Portal

// App.vue
<template>
  <!-- Rest of the code -->
  <Portal/>
  <!-- Define a named mount target -->
  <Portal name="modals"/>
</template>
<script lang="ts" setup>
import {Portal} from "vue3-mount"
</script>

At-least one portal is required.

Mounting the component

// SomeComponent.vue
<template>
  <button @click="mountModal">Mount Modal</button>
</template>
<script lang="ts" setup>
import {h}        from "vue"
import {useMount} from "vue3-mount"
import Modal      from "./components/Modal.vue"

const mount = useMount()

function mountModal() {
  const node = mount(() => h(Modal, {
    // props
  }))

  // or mount to a named mount target
  const node = mount(() => h(Modal, {
    // props
  }), 'modals')

  // unmount the component
  node.unmount()
  // or destroy the component
  node.remove()
}

</script>

Using the vMount directive

// Modal.vue
<transition name="fade" appear>
    <div v-mount>
      <!-- Rest of the code -->
    </div>
</transition>
<script lang="ts" setup>
import {vMount} from "vue3-mount"
</script>

vMount is a wrapper around native vShow directive, but it also handles transitions for custom mounted components.

Unmount the component

// Modal.vue
<script lang="ts" setup>
import {getNode} from "vue3-mount"

const unmount = getNode()
// const unmount = getNode(()=> /** beforeUnmountHook */)

// unmount the component
// vMount directive will handle the transition
unmount()
// or if you want to destroy the component instantly
unmount.force()

</script>

Using Options API

Mounting the component

// SomeComponent.vue
<template>
  <button @click="mountModal">Mount Modal</button>
</template>
<script lang="ts">
import {defineComponent, h} from "vue"
import Modal                from "./components/Modal.vue"

export default defineComponent({
  methods: {
    mountModal() {
      const node = this.$vueMount(() => h(Modal, {
        // props
      }))

      // or mount to a named mount target
      const node = this.$vueMount(() => h(Modal, {
        // props
      }), 'modals')

      // unmount the component
      node.unmount()
      // or destroy the component
      node.remove()
    }
  }
})

</script>

Accessing Node instance from Mounted component

// Modal.vue
<script lang="ts">
import {defineComponent} from "vue"
import {NodeMixin}       from "vue3-mount"

export default defineComponent({
  mixins: [NodeMixin],
  methods: {
    unmount() {
      this.$node.unmount()
    },
    destroy() {
      this.$node.remove()
    }
  }
})
</script>

Todo

  • Add unit tests