Introducing a new way to review your PRs.

Read the announcement

pingdotgg / uploadthing

File uploads for modern web devs

View on GitHub

19 documents · Updated Oct 2, 2026

docs / vue-sdk

Vue SDK

The Vue SDK gives Vue applications a typed way to connect file selection to UploadThing upload routes. It offers a composable for custom upload interfaces, ready-made button and dropzone components, file-selection utilities, and a style entry point. See the framework and SDK overview for the wider product map, and compare the Solid, Svelte, Nuxt, and Expo SDKs for other client targets.

Vue upload surface

The Vue upload surface connects a client-side endpoint choice to the shared UploadThing upload service. Applications first create helpers for their file router, then choose between a composable and prebuilt components according to how much control the UI needs.

Typed helper generation

home/…/useUploadThing.ts exposes generateVueHelpers, which binds a Vue application to a typed file router. The generated helpers include useUploadThing for custom interfaces and the lower-level client upload helpers for applications that need to manage their own UI.

The helper setup accepts an optional UploadThing URL and fetch function. This lets an application use its normal API route by default while still supporting a different service location or request behavior when its deployment needs one.

References: packages/…/useUploadThing.ts• L160-188 packages/…/types.ts• L20-50 packages/…/index.ts• L1-5

Endpoint metadata

The SDK uses endpoint metadata to learn which file types and quantities the selected route permits. This metadata lets both the composable and the ready-made controls present the right client affordances before an upload starts.

References: packages/…/useUploadThing.ts• L39-56 packages/…/useUploadThing.ts• L144-156 packages/…/button.tsx• L109-127 packages/…/dropzone.tsx• L132-154

Upload composable

The useUploadThing composable is the main escape hatch for a custom Vue upload experience. It exposes an upload action, reactive upload state, and the selected route configuration while keeping endpoint input and output types tied to the file router.

Upload lifecycle

The composable coordinates file preparation, upload progress, completion, errors, and cancellation through callbacks. A caller can change files before upload, attach request headers, pass route input, observe progress, wait for the client result, or stop the request with an abort signal.

This diagram shows how a Vue caller moves from selected files to a result or an error while the composable manages transient state.

flowchart LR
    A[Selected files] --> B[Optional file preparation]
    B --> C[Start upload for endpoint]
    C --> D[Progress and upload-begin events]
    C --> E[Abort signal]
    D --> F[Client upload result]
    F --> G[Completion callback]
    C --> H[Upload error]
    E --> I[Aborted upload]
    H --> J[Error callback]

The composable resets its upload state after completion, failure, or cancellation. Upload results carry the server data defined by the endpoint, so the Vue application can continue its own domain flow without losing route-level type checks.

References: packages/…/useUploadThing.ts• L58-157 packages/…/types.ts• L52-120

Upload components

The generated components provide common upload flows without requiring each application to build file input and progress behavior from scratch. Both components use the same endpoint contract and upload callbacks as the composable, then add a focused selection interface.

Upload button

generateUploadButton creates a compact file-picker control for one or more files allowed by the route. In automatic mode it starts after file selection; in manual mode it holds the selected files until the user confirms and can clear them before submission.

The button reflects route readiness, disabled state, upload progress, and cancellation in its visible state. Applications can supply class names, state-aware appearance rules, and custom content without replacing the upload flow.

References: packages/…/button.tsx• L49-65 packages/…/button.tsx• L67-194 packages/…/button.tsx• L207-343 packages/…/types.ts• L122-190

Upload dropzone

generateUploadDropzone creates a larger selection area for file picking, dragging, and dropping. It checks the selected files against the route's accepted types, size limits, and quantity limits before it passes accepted files to the upload flow.

The dropzone also supports keyboard selection and optional paste handling. Its state-aware content can show drag activity, permitted content, progress, cancellation, and manual confirmation while the same completion and error callbacks remain available.

References: packages/…/dropzone.tsx• L70-93 packages/…/dropzone.tsx• L95-230 packages/…/dropzone.tsx• L232-437

File selection utilities

The exported useDropzone utility supports applications that need dropzone behavior without the packaged visual component. It returns reactive selection state, element prop builders, and element references so a custom Vue view can decide its own markup while retaining file acceptance and drag behavior.

The utility treats file selection as a browser interaction rather than an upload itself. It reports accepted files through the supplied callback, while the application decides whether and when to call useUploadThing.

References: packages/…/dropzone.tsx• L439-463 packages/…/dropzone.tsx• L513-633 packages/…/dropzone.tsx• L635-711 packages/…/index.ts• L1-5

Styles and customization

The SDK includes a CSS entry point for the utility classes used by its default controls. Applications can import @uploadthing/…/styles.css when their styling setup needs the SDK's base Tailwind layers.

The button and dropzone also accept state-aware appearance and content rules. These rules receive the current upload state and file context, which allows an application to adapt its visual language without changing endpoint or upload behavior.

References: packages/…/styles.css• L1-3 packages/…/package.json• L15-27 packages/…/button.tsx• L27-65 packages/…/dropzone.tsx• L45-85

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the generated helper contract aligned with the endpoint input and output types exposed by the shared UploadThing client.
  • Keep button and dropzone route-readiness rules aligned with the endpoint metadata contract. A mismatch can show a control as usable while the route rejects the selection.
  • Keep the composable callback and abort behavior aligned with the component-owned cancellation behavior. Components must continue to surface an aborted upload separately from an upload error.
  • Keep the public exports and the package CSS export aligned when adding or removing Vue-facing capabilities.

Important failure modes

TriggerConsequenceGuard
The client cannot load endpoint metadataThe control remains in its not-ready state and does not offer a valid file choice.Expose the correct UploadThing URL or a fetch function that can reach the route.
A selected file fails route type, size, or quantity rulesThe dropzone passes no accepted files to the upload callback.Use the permitted-content display and route metadata to guide the user before upload.
The caller aborts an active uploadThe operation ends as an aborted upload rather than a completed result.Handle the abort callback in generated components or catch UploadAbortedError in a custom flow.
A route requires input but the caller omits itThe typed upload call cannot satisfy the endpoint contract.Pass the endpoint input through the composable or component props.

Key files

FileWhy to read it
packages/…/index.tsShows the public Vue SDK surface.
packages/…/useUploadThing.tsExplains helper generation, route metadata, and the shared upload lifecycle.
packages/…/types.tsDefines the typed options and common component contract.
packages/…/button.tsxShows the compact button upload experience and its customization points.
packages/…/dropzone.tsxShows the drag-and-drop component and the reusable file-selection utility.
packages/…/styles.cssDefines the SDK style entry point used by packaged controls.
packages/…/README.mdGives the shortest end-to-end example of helper generation and component use.