published fresh until

How do I add file uploads to a Next.js app without building a backend?

Summary As of November 2026, UploadThing provides a typed FileRouter, route limits and client upload components for hosted storage. Tailwind v3 uses withUt; v4 uses CSS imports and configures component discovery with @source

Not for uploads to your own S3 or R2 bucket; see upload-413-direct-to-s3-r2-presigned

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

As of November 2026, use UploadThing’s typed FileRouter and client upload components for hosted storage. Do first: identify your Tailwind major version before copying style setup; v3 and v4 use different configuration.

The problem

Direct-to-storage uploads can require a bucket, CORS, signed URLs, progress and metadata. Agents often generate a server action that receives the whole file, which hits body limits and ties up the server.

What the source says

  • UploadThing SDKs are MIT licensed. The docs at docs.uploadthing.com (App Router guide) describe: install uploadthing and @uploadthing/react; set UPLOADTHING_TOKEN from the dashboard; define a FileRouter (for example f({ image: { maxFileSize: "4MB", maxFileCount: 1 } })); .middleware(...) runs on the server before upload and throwing UploadThingError blocks it; .onUploadComplete(...) runs after upload; export routes with createRouteHandler; generate UploadButton and UploadDropzone typed with your router.
  • Tailwind v3 uses the withUt config wrapper. For Tailwind v4 CSS configuration, import tailwindcss and uploadthing/tw/v4, then add an @source pointing at @uploadthing/react/dist; the path depends on your project structure (theming source, v3 and v4 tabs). The App Router guide also shows an optional SSR plugin in the root layout to avoid a loading state.
  • Note the trade: it is a hosted service plus an open SDK. Storage is theirs, so check pricing and data location for your case.

How to describe it to the agent

Suggested prompt:

Add avatar upload with UploadThing in this Next.js App Router project. Define one route with image only, max 4 MB, 1 file. In middleware check our existing session and throw UploadThingError if not signed in. In onUploadComplete save the file URL to the user row. Use UploadDropzone styled with our tokens. Never put UPLOADTHING_TOKEN in client code.

Common mistakes to check for

  • Skipping the middleware, so anyone can upload.
  • Trusting the client-side limit only (the route config is the real limit).
  • Components used in a server component; they need "use client".
  • Token committed to the repo.

Limits

The Next.js integration needs a server route. For authenticated uploads, add authentication middleware. The hosted-storage tradeoff remains; choose data location and service terms for your application.

Sources

Started from a post by @pingdotgg, packaged by the editor. Original post

Subjects

More in prompting

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# How do I add file uploads to a Next.js app without building a backend?
Summary: As of November 2026, UploadThing provides a typed FileRouter, route limits and client upload components for hosted storage. Tailwind v3 uses withUt; v4 uses CSS imports and configures component discovery with `@source`
Copy for agent
get the whatworks thread uploadthing-nextjs-upload-button-dropzone and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread uploadthing-nextjs-upload-button-dropzone
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks