Nuxt SDK
The Nuxt SDK is a Nuxt module that connects an UploadThing file router to Nuxt's server and client layers. It adds a server upload endpoint, typed Vue upload helpers, ready-made upload controls, shared runtime settings, and optional styles so a Nuxt project can use the normal UploadThing upload lifecycle.
Module registration
The @uploadthing/nuxt module runs during Nuxt setup. It turns one module entry into the server route, auto-imports, components, router alias, runtime settings, and style support that the application needs.
Nuxt project setup
An application enables the integration by adding @uploadthing/nuxt to the modules list in nuxt.config.ts. The module supports Nuxt 3 and uses uploadthing as the peer package for the server route and client protocol. The minimal example shows the intended project-level registration. (Framework SDKs)
References: packages/…/README.md• L11-41 packages/…/module.ts• L38-56 examples/…/nuxt.config.ts• L1-6
Router discovery
The file router is the application-owned definition of UploadThing endpoints. The module expects it at ~/server/uploadthing by default, maps that path to the runtime, and watches it so Nuxt can restart when the router is created or removed. A missing router uses an empty typed router and emits a warning. This keeps the project type-aware while signaling that no upload endpoints are ready yet.
References: packages/…/module.ts• L21-32 packages/…/module.ts• L57-88 packages/…/router.ts• L1-5 packages/…/README.md• L48-85
Runtime capabilities
The module exposes the same UploadThing route contract through Nuxt's server runtime and Vue's client runtime. The server side owns the application router and request handling. The client side reads that router's endpoint types and sends upload requests through the shared UploadThing client.
Server upload endpoint
Nuxt receives UploadThing requests at /api/uploadthing. The runtime handler reads the module's uploadthing runtime configuration and passes the application router plus that configuration to the H3 UploadThing adapter. H3 is Nuxt's request boundary here, so the shared handler can process Nuxt events without changing the UploadThing route contract.
References: packages/…/module.ts• L109-113 packages/…/uploadthing.ts• L1-25 packages/…/h3.ts• L22-40
Client helpers
The module auto-imports useUploadThing and registers UploadButton and UploadDropzone as Nuxt components. Each is generated from the Vue SDK with the application's UploadRouter type. This gives pages a typed composable for custom interfaces and typed controls for the common button and drag-and-drop flows. (Vue SDK)
References: packages/…/module.ts• L90-107 packages/…/useUploadThing.ts• L1-5 packages/…/button.ts• L1-7 packages/…/dropzone.ts• L1-7
Upload state
The Vue runtime discovers the selected endpoint's permitted file information before upload. It then exposes upload start, busy state, route data, progress, completion, error, and abort behavior through the shared Vue upload layer. The button and dropzone use the same state model, so changing the presentation does not change the server route or upload protocol. (Vue SDK)
References: packages/…/useUploadThing.ts• L39-56 packages/…/useUploadThing.ts• L58-157 packages/…/button.tsx• L109-180 packages/…/dropzone.tsx• L132-230
Upload lifecycle
The Nuxt integration joins a page-level upload control to the application router through one server endpoint. The client first learns the endpoint rules, then uses the UploadThing client flow to transfer files and report the result to the page.
The following diagram shows the high-level relationship between the Nuxt page, the generated client capability, the Nuxt server boundary, and the UploadThing service.
flowchart LR
Page[Nuxt page] --> UI[UploadButton, UploadDropzone, or useUploadThing]
UI --> Rules[Endpoint rules]
UI --> API[/api/uploadthing]
API --> Router[Application upload router]
Router --> Service[UploadThing service]
Service --> Result[Upload result and callbacks]
Result --> UI
Endpoint selection
An upload control selects an endpoint by name from UploadRouter. The client uses the endpoint's server-defined file rules to set accepted types and quantity before it starts an upload. Manual mode lets the page hold selected files until it starts the upload; automatic mode starts after selection or drop.
References: packages/…/README.md• L61-84 packages/…/useUploadThing.ts• L39-55 packages/…/button.tsx• L120-179 packages/…/dropzone.tsx• L147-192
Transfer feedback
During transfer, the shared Vue layer tracks overall progress and per-file progress. It returns the completed result or reports a typed UploadThing error to the configured page callbacks. Abort actions stop the current transfer and leave the control ready for a later attempt.
References: packages/…/useUploadThing.ts• L67-141 packages/…/button.tsx• L140-155 packages/…/dropzone.tsx• L167-182
Style integration
The module aims to make the generated controls usable without a separate style step while still fitting a Nuxt project that already uses Tailwind CSS. The injectStyles option controls this automatic support and defaults to enabled.
Default stylesheet
When the Nuxt project does not use @nuxtjs/tailwindcss, the module adds the Vue SDK stylesheet to Nuxt's global CSS list. This supplies the base utility layers expected by the generated controls.
References: packages/…/module.ts• L24-31 packages/…/module.ts• L99-101 packages/…/module.ts• L116-127 packages/…/styles.css• L1-3
Tailwind support
When Tailwind is present, the module avoids adding a second global stylesheet. Instead, it creates a Tailwind configuration fragment that includes the Vue SDK content and UploadThing plugin, then adds that fragment to the Nuxt Tailwind configuration. This lets the project keep its own Tailwind setup while making UploadThing styles available.
References: packages/…/module.ts• L121-163 packages/…/plugin.ts• L1-40
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the configured router path, the
#uploadthing-routeralias, and the file-watch restart rule aligned. A mismatch can leave the server and generated client types pointed at different routers. - Keep
/api/uploadthingaligned with the URL used by the generated Vue client. A route-path change affects every auto-registered control and composable. - Keep the
UploadRoutertype export aligned with the router value. The Nuxt controls and composable derive their endpoint types from that export. - Preserve the runtime configuration contract between module setup and the server handler. Deployment values must reach the H3 route with empty optional values treated as unset.
- When changing automatic styles, check both branches: plain Nuxt CSS injection and the Tailwind module configuration path.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The configured router file does not exist | Nuxt uses an empty router. Controls cannot load usable endpoint rules and the module logs a warning. | Create the router at the configured path or set uploadthing.routerPath to the application path. |
The router exports a value that is not used as uploadRouter | The server handler and generated client types do not share the application's endpoints. | Export the configured router as uploadRouter and derive UploadRouter from that value. |
| The server endpoint path and client request URL differ | Endpoint discovery or upload requests fail at the Nuxt boundary. | Treat /api/uploadthing as a shared client-server contract when changing either side. |
| Automatic style injection is disabled without an equivalent project style setup | Upload controls render without their expected base styles. | Add the required styles through the application or enable injectStyles. |
| Tailwind is detected but its configuration cannot include the generated UploadThing fragment | Tailwind-based control styles are missing from the built page. | Keep the Nuxt Tailwind module configuration path valid when changing Tailwind settings. |
Key files
| File | Why to read it |
|---|---|
| packages/…/module.ts | Defines the Nuxt registration contract, router discovery, runtime settings, auto-registered capabilities, server route, and style behavior. |
| packages/…/uploadthing.ts | Shows how Nuxt runtime configuration and the application router reach the H3 UploadThing handler. |
| packages/…/router.ts | Shows the fallback router shape and the type boundary expected from an application router. |
| packages/…/useUploadThing.ts | Shows how Nuxt gets typed Vue upload helpers from the application router. |
| packages/…/button.ts | Shows the Nuxt-facing typed button capability. |
| packages/…/dropzone.ts | Shows the Nuxt-facing typed drag-and-drop capability. |
| packages/…/useUploadThing.ts | Explains the shared client state and upload feedback used by the Nuxt composable and controls. |
| packages/…/h3.ts | Explains the H3 boundary that connects Nuxt events to the shared UploadThing route handler. |
| packages/…/README.md | Provides the intended setup and application usage shape for the module. |