Dynamically Mount Components With Vue Mountable

Install & Download:

$ npm install vue-mountable
$ pnpm add vue-mountable


Mountable is a lightweight and flexible Vue 3 component that simplifies the process of dynamically mounting components in your Vue applications.

It can be useful in creating interactive elements like popups, tooltips, modals, and more.

How to use it:

1. Improt the VueMountable after installation.

import { createApp } from 'vue';
import { VueMountable } from 'vue-mountable';
const app = createApp();

2. Create a mountable component as follows:

    <h1> MODAL </h1>

3. Mount the modal component with the mountComponent.

import modal from './modal.vue';
const { id, vNode, el, destroy } = mountComponent({
  component: modal,
  props: {
    title: 'Test'
  emits: {
    onExample() {
      alert('This works nicely!');

4. Remove a dynamically mounted Vue component from the DOM.

const { destroy } = mountComponent(modal);


Dynamically Mount Components With Vue Mountable

Add Comment