@uploadthing/nuxt
Nuxt UploadThing Module
Nuxt module for getting started with UploadThing in your Nuxt app.
Quick Setup
- Add
@uploadthing/nuxtanduploadthingdependencies to your project
# Using pnpm
pnpm add -D @uploadthing/nuxt
pnpm add uploadthing
# Using yarn
yarn add --dev @uploadthing/nuxt
yarn add uploadthing
# Using npm
npm install --save-dev @uploadthing/nuxt
npm install uploadthing
# Using bun
bun add -D @uploadthing/nuxt
bun add uploadthing
- Add
@uploadthing/nuxtto themodulessection ofnuxt.config.ts
export default defineNuxtConfig({
modules: ["@uploadthing/nuxt"],
});
That's it! You can now use @uploadthing/nuxt in your Nuxt app ✨
Usage
For full documentation, see the UploadThing docs
- Create an upload router in your app:
// server/uploadthing.ts
import { createUploadthing, UTFiles } from "uploadthing/h3";
import type { FileRouter } from "uploadthing/h3";
const f = createUploadthing();
/**
* This is your Uploadthing file router. For more information:
* @see https://docs.uploadthing.com/api-reference/server#file-routes
*/
export const uploadRouter = {
videoAndImage: f({
image: {
maxFileSize: "4MB",
maxFileCount: 4,
acl: "public-read",
},
video: {
maxFileSize: "16MB",
},
})
.middleware(({ event, files }) => {
// ^? H3Event
// Return some metadata to be stored with the file
return { foo: "bar" as const };
})
.onUploadComplete(({ file, metadata }) => {
// ^? { foo: "bar" }
console.log("upload completed", file);
}),
} satisfies FileRouter;
export type UploadRouter = typeof uploadRouter;
- Mount a component in your app and start uploading files:
<script setup lang="ts">
const alert = (msg: string) => {
window.alert(msg);
};
</script>
<template>
<div>Playground</div>
<UploadButton
:config="{
endpoint: 'videoAndImage',
onClientUploadComplete: (res) => {
console.log(`onClientUploadComplete`, res);
alert('Upload Completed');
},
onUploadBegin: () => {
console.log(`onUploadBegin`);
},
}"
/>
<UploadDropzone
:config="{
endpoint: 'videoAndImage',
onClientUploadComplete: (res) => {
console.log(`onClientUploadComplete`, res);
alert('Upload Completed');
},
onUploadBegin: () => {
console.log(`onUploadBegin`);
},
}"
/>
</template>
Wow, that was easy!
Development
From workspace root:
# Install dependencies
pnpm install
# Develop with the playground
pnpm dev
# Run ESLint
pnpm lint
Related Packages
@uploadthing/dropzone
307,672
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 7.1.10 | ^3.0 | MIT | |
| 7.1.9 | ^3.0 | MIT | |
| 7.1.8 | ^3.0 | MIT | |
| 7.1.7 | ^3.0 | MIT | |
| 7.1.6 | ^3.0 | MIT | |
| 7.1.5 | ^3.0 | MIT | |
| 7.1.4 | ^3.0 | MIT | |
| 7.1.3 | ^3.0 | MIT | |
| 7.1.2 | ^3.0 | MIT | |
| 7.1.1 | ^3.0 | MIT | |
| 7.1.0 | ^3.0 | MIT | |
| 7.0.3 | ^3.0 | MIT | |
| 7.0.2 | ^3.0 | MIT | |
| 7.0.1 | ^3.0 | MIT | |
| 7.0.0 | ^3.0 | MIT | |
| 6.5.10 | ^3.0 | MIT | |
| 6.5.9 | ^3.0 | MIT | |
| 6.5.8 | ^3.0 | MIT | |
| 6.5.7 | ^3.0 | MIT | |
| 6.5.6 | ^3.0 | MIT | |
| 6.5.5 | ^3.0 | MIT | |
| 6.5.4 | ^3.0 | MIT | |
| 6.5.3 | ^3.0 | MIT | |
| 6.5.2 | ^3.0 | MIT | |
| 6.5.1 | ^3.0 | MIT | |
| 6.5.0 | ^3.0 | MIT |
Pre-releases (69)
| Version | Released | Vue | License |
|---|---|---|---|
| 7.1.9-canary.112f5c8 | ^3.0 | MIT | |
| 7.1.8-canary.07fd596 | ^3.0 | MIT | |
| 7.1.8-canary.b547b29 | ^3.0 | MIT | |
| 7.1.8-canary.35d7da3 | ^3.0 | MIT | |
| 7.1.8-canary.e657b69 | ^3.0 | MIT | |
| 7.1.7-canary.22c29ff | ^3.0 | MIT | |
| 7.1.6-canary.8a46260 | ^3.0 | MIT | |
| 7.1.5-canary.18c292a | ^3.0 | MIT | |
| 7.1.5-canary.8479c92 | ^3.0 | MIT | |
| 7.1.5-canary.63144 | ^3.0 | MIT | |
| 7.1.4-canary.4f4f9b9 | ^3.0 | MIT | |
| 7.1.3-canary.68d6e15 | ^3.0 | MIT | |
| 7.1.2-canary.2352c0f | ^3.0 | MIT | |
| 7.1.2-canary.0fa10f9 | ^3.0 | MIT | |
| 7.1.1-canary.1d74d85 | ^3.0 | MIT | |
| 7.1.1-canary.56681d4 | ^3.0 | MIT | |
| 7.0.4-canary.7c2c71a | ^3.0 | MIT | |
| 7.0.4-canary.266d605 | ^3.0 | MIT | |
| 7.0.4-canary.8bc74c6 | ^3.0 | MIT | |
| 7.0.3-canary.0c0091e | ^3.0 | MIT | |
| 7.0.3-canary.bd444ad | ^3.0 | MIT | |
| 7.0.3-canary.463ce07 | ^3.0 | MIT | |
| 7.0.3-canary.c184a9f | ^3.0 | MIT | |
| 7.0.3-canary.893338b | ^3.0 | MIT | |
| 7.0.3-canary.55eff26 | ^3.0 | MIT | |
| 7.0.3-canary.0a6befe | ^3.0 | MIT | |
| 7.0.2-canary.7bba659 | ^3.0 | MIT | |
| 6.5.10-canary.026732f | ^3.0 | MIT | |
| 6.5.10-canary.780987b | ^3.0 | MIT | |
| 6.5.10-canary.cc7da66 | ^3.0 | MIT |
Showing the latest 30 of 69. See every release on npm