File Uploads

Drag-and-drop file uploads with UploadThing, progress tracking, and a file manager grid.

Add a complete file upload system in ~8 minutes. Includes drag-and-drop upload zone, progress tracking, file grid, and delete — all backed by UploadThing (S3) and Prisma.

What's Included

FileDescription
file-manager.tsxPage layout — combines FileGrid + UploadZone
file-grid.tsxResponsive grid of file cards with empty state
file-card.tsxName, size, type icon, date, download/delete actions
upload-zone.tsxDrag-and-drop upload with progress bar and validation
hooks/features/use-files.tsuseFiles, useUploadFile, useDeleteFile hooks
lib/features/uploadthing.tsServer-side UploadThing router with auth + file validation

Setup

1

Install dependencies

pnpm add uploadthing @uploadthing/react
2

Add environment variables

UPLOADTHING_TOKEN="your-uploadthing-token"

Get your token from uploadthing.com → Your App → API Keys.

3

Create the UploadThing route handler

Create app/api/uploadthing/route.ts:

import { createRouteHandler } from "uploadthing/next"
import { uploadRouter } from "@/lib/features/uploadthing"

export const { GET, POST } = createRouteHandler({ router: uploadRouter })
4

Create the files API routes

Create app/api/files/route.ts (GET — list user files) and app/api/files/[id]/route.ts (DELETE — remove a file). See README.md in components/features/file-uploads/ for full implementations.

5

Add to dashboard

// app/(dashboard)/dashboard/files/page.tsx
import { FileManager } from "@/components/features/file-uploads/file-manager"

export default function FilesPage() {
  return <FileManager />
}

The UploadedFile model is already in prisma/schema.prisma. Run pnpm prisma db push if you haven't already.

Environment Variables

VariableRequiredDescription
UPLOADTHING_TOKENYesUploadThing project token

Verification

  1. Start dev: pnpm dev
  2. Navigate to /dashboard/files
  3. Drag a file onto the upload zone — progress bar should appear
  4. File appears in the grid after upload completes
  5. Click download — verify the file URL works
  6. Click delete — file is removed from the grid and storage
  7. Check UploadThing dashboard to confirm files are stored

Demo Mode — Explore freely. Some actions are restricted. demo@launchfst.dev / demo1234

Get LaunchFst →