Web: Vue
@nitrakit/vue gives you a composable that creates the editor and two components that show
it. It builds on @nitrakit/web: read the JavaScript page for requirements, the
license key, media and export. Everything from @nitrakit/web is re-exported.
npm install @nitrakit/vue
Show the editor
useNitrakitEditor creates an editor when the component mounts and frees it when it
unmounts. It returns a ref that's null until the editor is ready.
<script setup lang="ts">
import { useNitrakitEditor, NitrakitPreview, NitrakitEditor } from '@nitrakit/vue'
const editor = useNitrakitEditor({
width: 1080,
height: 1920,
async onRequest(request) {
if (request.kind === 'addMedia') {
const file = await openMyMediaLibrary()
return file ? { source: (await editor.value!.addMedia(startUpload(file), file)).source } : null
}
// anything else: the built-in picker
},
})
</script>
<template>
<NitrakitPreview :editor="editor" style="height: 60vh" />
<NitrakitEditor :editor="editor" style="height: 320px" />
</template>
Call load() and setLicense() once at start-up, for example in main.ts before mounting
the app. To change chrome or layout later, pass a getter: useNitrakitEditor(() => ({ … })).