Skip to content

Vue API Reference ​

API Index ​

createVueAdapter() ​

Creates a Makoo adapter that mounts Vue components.

Type ​

ts
function createVueAdapter(): VueMountAdapter;

Returns ​

Returns a resolvable Makoo mount adapter for Vue components.

Details ​

The adapter uses createApp(artifact, { makoo }) to create a Vue app, installs every plugin registered with VuePlugin, and mounts the app into the task's mountPoint. It calls app.unmount() when the task is unmounted.

Mounting or unmounting failures throw VueAdapterError.

Example ​

ts
import { createMakoo, inject } from '@makoojs/core';
import { createVueAdapter } from '@makoojs/vue';
import Panel from './Panel.vue';

const makoo = createMakoo({
	adapters: [createVueAdapter()]
});

makoo.start([
	inject({ injectAt: '#app', artifact: Panel })
]);

VuePlugin ​

Register Vue plugins before calling start(). Each Vue app mounted afterward installs those plugins.

Type ​

ts
const VuePlugin: {
	getPlugins(): Plugin[];
	use<T extends Plugin>(plugin: T): void;
	usePlugins(...plugins: Plugin[]): void;
	clear(): void;
};

Methods ​

MethodReturnsDescription
getPlugins()Plugin[]Returns a copy of the current plugin list
use(plugin)voidRegisters one plugin; the same plugin instance is stored once
usePlugins(...plugins)voidRegisters multiple plugins
clear()voidRemoves every plugin

Example ​

ts
import { createPinia } from 'pinia';
import { VuePlugin } from '@makoojs/vue';

VuePlugin.use(createPinia());

VueAdapterError ​

Error class used when the Vue adapter cannot mount or unmount a component. It extends AdapterError.

Type ​

ts
class VueAdapterError extends AdapterError {
	constructor(
		message: string,
		issues?: MakooIssue[],
		code?: string,
		cause?: Error
	);
}

When code is omitted, it defaults to ErrorCode.ADAPTER_MOUNT_FAIL.

TypeScript types ​

VueMountAdapter ​

ts
type VueMountAdapter = ResolvableMountAdapter<
	VueMountArtifact,
	VueMountHandle,
	VueMountInstance
>;

VueMountProps ​

Props received by the Vue root component.

ts
type VueMountProps = {
	makoo: MakooContext;
};

VueMountArtifact ​

ts
type VueMountArtifact = Component;

VueMountHandle ​

ts
type VueMountHandle = App<Element>;

VueMountInstance ​

ts
type VueMountInstance = ComponentPublicInstance;

See Component Injection for a component example and the makoo prop. See MakooContext for the full method reference.