Published
What you are building
Vue components that upload from the browser straight to Fileboy, with drag and drop, progress and errors built in, and the file's ID in a v-model. You do not write an upload endpoint. It needs Vue 3.5 or later.
1. Install and add the plugin
npm install @cd2/fileboy-vueimport { createApp } from "vue"
import { createFileboy } from "@cd2/fileboy-vue"
import App from "./App.vue"
createApp(App)
.use(createFileboy({ publicKey: "YOUR_PUBLIC_KEY" }))
.mount("#app")The public key is safe in browser code: it can upload, and you can limit it to your own sites with allowed origins. Create a free app and copy it from the Keys page.
2. Add the uploader
<script setup lang="ts">
import { ref } from "vue"
import { FileUploader, FileboyImage } from "@cd2/fileboy-vue"
const avatar = ref<string>()
function save(file: { id: string }) {
// send file.id to your own server to store against the user
}
</script>
<template>
<FileUploader v-model="avatar" allow="image/*" @uploaded="save" />
<FileboyImage
v-if="avatar"
:id="avatar"
:transforms="[{ type: 'resize', width: 200, height: 200, fit: 'cover' }]"
alt="Your avatar"
/>
</template>v-model holds the file's ID, and the uploaded event gives you the file's details when an upload finishes. Use MultiFileUploader for several files, with an array in the v-model.
3. Decide who may upload
With only a public key, anyone who can reach your page can upload. To have your server decide, give the plugin an uploadToken: a URL on your server that returns a short-lived token to signed-in users. See signed uploads for user content.
Reading a file or image needs no key, so the image URLs work in any <img> tag, unless the app requires signed URLs.
Checked against the current libraries in November 2026. Found something that no longer works? Tell us.