# Vue integration Install the editor and its Fabric peer dependency: ```bash npm install @bensitu/image-editor fabric ``` The core package is framework-agnostic. In Vue, create the editor in `onMounted`, pass HTMLElement refs to `init()`, and dispose it in `onBeforeUnmount`. Use `shallowRef` and `markRaw` so Vue does not deep-reactivize the editor instance or Fabric objects. For Nuxt or SSR, render the editor inside `` and initialize it only from `onMounted`. ## Composable example ```ts import { markRaw, onBeforeUnmount, onMounted, ref, shallowRef } from 'vue'; import * as fabric from 'fabric'; import { ImageEditor } from '@bensitu/image-editor'; import type { ImageEditorOptions, ImageEditorState } from '@bensitu/image-editor'; export function useImageEditor(options: ImageEditorOptions = {}) { const canvasRef = ref(null); const containerRef = ref(null); const editor = shallowRef(null); const state = shallowRef(null); const busy = ref(false); onMounted(() => { const canvas = canvasRef.value; if (!canvas) return; const instance = markRaw( new ImageEditor(fabric, { ...options, onImageChanged: (nextState, context) => { state.value = nextState; options.onImageChanged?.(nextState, context); }, onBusyChange: (isBusy, context) => { busy.value = isBusy; options.onBusyChange?.(isBusy, context); }, }), ); instance.init({ canvas, canvasContainer: containerRef.value, zoomInButton: null, zoomOutButton: null, imageInput: null, maskList: null, annotationList: null, }); editor.value = instance; }); onBeforeUnmount(() => { editor.value?.dispose(); editor.value = null; }); return { canvasRef, containerRef, editor, state, busy, }; } ``` ## SFC example ```vue ``` ## State guidance Keep `ImageEditor` in a `shallowRef` and wrap the instance with `markRaw`. Store `ImageEditorState` snapshots or serializable view-model data, not Fabric objects. ## Responsive layout Call `editor.value?.resizeToContainer()` after tabs, dialogs, or accordions reveal the editor. Use `editor.value?.relayout()` when the host layout changed and the editor should refresh canvas geometry for the existing image without reloading it.