Piral Vue 3 Plugin

1.10.3 · active · verified Sun Apr 19

piral-vue-3 is a plugin designed to seamlessly integrate Vue 3 components within a Piral microfrontend application. It enables developers to build 'pilets' (microfrontends) using Vue 3, which can then be dynamically loaded and rendered by a Piral instance (the 'shell' application). The current stable version is 1.10.3, with minor point releases occurring frequently, typically addressing dependency updates, bug fixes, and improvements across the Piral ecosystem. Key differentiators include its tight integration with the Piral Pilet API, allowing Vue 3 components to leverage the Piral communication layer and shared services, and its focus on enabling a multi-framework approach within a single microfrontend host. It abstracts away the complexities of mounting and unmounting Vue 3 applications within the Piral lifecycle, providing a robust solution for incorporating Vue 3 into larger, heterogeneous microfrontend architectures.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a Piral application with the `piral-vue-3` plugin and register a simple Vue 3 component as a pilet page. It sets up a basic Piral factory, includes the Vue 3 plugin, and shows how a mock pilet could register a Vue component route.

import { Piral, createPiralFactory } from 'piral';
import { createVue3Api } from 'piral-vue-3';
import { createApp, defineComponent } from 'vue';

const MyVueComponent = defineComponent({
  template: '<div>Hello from Vue! Count: {{ count }}</div>',
  data() {
    return { count: 0 };
  },
  mounted() {
    setInterval(() => {
      this.count++;
    }, 1000);
  }
});

const piralApp = createPiralFactory({
  requestPilets() {
    return Promise.resolve([
      {
        name: 'my-vue-pilet',
        version: '1.0.0',
        spec: 'v1',
        hash: 'abc',
        dependencies: {},
        setup(app) {
          app.registerPage('/vue-page', MyVueComponent);
          app.showNotification('Vue Pilet Loaded!', { autoClose: 2000 });
        }
      }
    ]);
  },
  plugins: [createVue3Api()]
});

// In a real Piral application, the Piral instance would be mounted to a DOM element.
// For demonstration, we'll just show the setup.
// Piral renders its components into a designated DOM container.
// For a full Piral app, this would be `render(<Piral instance={piralApp} />, document.querySelector('#app'))`.

console.log('Piral app with Vue 3 plugin initialized.', piralApp);
// Simulate a Piral app mounting cycle if needed for full execution context.
// In a browser environment, you'd mount `<Piral instance={piralApp} />` into your root element.

view raw JSON →