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 / expo-sdk

Expo SDK

The Expo SDK connects native document and media selection to UploadThing uploads in React Native apps. It gives an app typed helpers for an UploadThing router, applies each route’s file rules to the native picker, and sends the chosen assets through the normal UploadThing upload flow.

This page belongs to Frameworks and SDKs. For related web adapters, see the Vue SDK, Solid SDK, Svelte SDK, and Nuxt SDK.

SDK boundary

The SDK is the bridge between Expo’s native picker APIs and UploadThing’s client upload API. The app chooses an endpoint and opens the picker; the SDK handles native permissions, asset conversion, and upload state.

Helper factory

generateReactNativeHelpers binds an app’s typed FileRouter to an UploadThing API URL and a fetch function. It returns the normal React Native UploadThing helpers together with the two picker hooks, so picker uploads and direct uploads use the same client boundary. The API URL can be supplied by the app. A relative URL uses the Expo server origin or the host reported by Expo, and a custom fetch function can add app-specific request behavior.

References: packages/…/index.ts• L1-5 packages/…/index.ts• L13-23 packages/…/index.ts• L45-85

Picker hooks

useDocumentUploader and useImageUploader are endpoint-bound hooks. Each hook exposes one action for opening its native picker and an isUploading state value. The hook also accepts the shared UploadThing upload options, including endpoint input, progress, completion, error, headers, and cancellation behavior.

References: packages/…/document-picker.ts• L36-50 packages/…/document-picker.ts• L57-100 packages/…/image-picker.ts• L28-49 packages/…/image-picker.ts• L134-138 packages/…/types.ts• L52-120

Picker constraints

The native picker does not define upload rules on its own. Each hook reads the selected endpoint’s UploadThing route configuration and turns its allowed file types and maximum file count into native picker limits.

Document selection

The document helper translates UploadThing file groups into MIME filters. It supports named groups such as images, video, audio, PDF, and text, as well as broad file uploads. If the route allows more than one file, the document picker enables multi-select. A cancel action returns through the optional cancel callback without starting an upload.

References: packages/…/document-picker.ts• L15-34 packages/…/document-picker.ts• L52-73

Image selection

The image helper limits the native picker to images, videos, or both when the route permits those groups. It can use the device library or camera and checks the needed permission before opening either source. Editing is available for a single selection; multi-select disables editing so the picker can return all chosen assets.

References: packages/…/image-picker.ts• L15-26 packages/…/image-picker.ts• L49-107

Asset upload flow

The picker result is an Expo asset with a local URI, not yet an UploadThing file. The SDK turns each asset into a React Native form-compatible file and passes the group to the shared UploadThing client, which performs the endpoint upload and reports its state to the app.

The following flow shows how a native selection becomes an UploadThing result.

sequenceDiagram
    participant App as Expo app
    participant Hook as Picker hook
    participant Picker as Native picker
    participant Client as UploadThing client
    participant Server as UploadThing endpoint

    App->>Hook: Open picker for endpoint
    Hook->>Picker: Apply route type and count rules
    Picker-->>Hook: Return selected asset URIs
    Hook->>Hook: Read each URI as a file
    Hook->>Client: Start upload with files and route input
    Client->>Server: Request and use upload instructions
    Server-->>Client: Return upload result
    Client-->>App: Complete, progress, or error callbacks

Native file handoff

For each selected asset, the helper reads the local URI and preserves its name and MIME type when it creates a file. It also keeps the URI on that file because React Native FormData uses the URI to represent a local file. The resulting file list is then sent to startUpload with any typed endpoint input supplied to the picker action.

References: packages/…/document-picker.ts• L74-94 packages/…/image-picker.ts• L110-131

Upload state

The shared upload client marks the operation as active before it sends files and clears the state after success or failure. It can run a pre-upload file change, report progress, return server results after completion, and send typed upload errors to the supplied callbacks. This keeps picker-specific behavior separate from the UploadThing request lifecycle.

References: packages/…/use-uploadthing.ts• L57-90 packages/…/use-uploadthing.ts• L90-145 packages/…/types.ts• L52-120

Expo runtime contract

The Expo SDK depends on the app’s native runtime for picker access and on a reachable UploadThing API endpoint for upload control. These are app-level conditions: the SDK can select and prepare an asset only when the device can use the requested source and reach the configured server.

Native dependencies

The package expects compatible Expo document-picker and image-picker modules, React, React Native, and the UploadThing client package. The picker modules are peer requirements because the app supplies the native runtime in which they operate.

References: packages/…/package.json• L40-65

Server address

The helper resolves its endpoint from the supplied URL or from Expo-aware host settings. A device must be able to reach that resolved address; a host that works only inside the development machine is not a usable mobile endpoint.

References: packages/…/index.ts• L17-23 packages/…/index.ts• L54-73

Change checklist

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

  • Keep the document and image picker rules aligned with the shared route configuration contract. A change in file groups or file count can change both picker limits and upload acceptance.
  • Keep the native file shape aligned with React Native FormData. The local URI, file name, and MIME type must remain available when assets move into startUpload.
  • Keep the Expo URL fallback aligned with the app’s network model. Changes to host discovery or environment names can make picker selection succeed while the upload request cannot reach the server.
  • Keep picker hook options aligned with the shared UploadThing hook contract. Endpoint input and upload callbacks cross from the Expo adapter into the common client lifecycle.

Important failure modes

TriggerConsequenceGuard
The resolved API URL points to a host the device cannot reach.The picker opens, but the upload cannot start or finish.Set an explicit reachable URL or a valid Expo server origin.
The user denies the camera or media-library permission.No picker opens and no files are uploaded.Handle onInsufficientPermissions and provide an app-specific permission path.
The user cancels either picker.The action ends without an upload result.Handle onCancel when the surrounding UI must restore or keep its state.
A route permits file types or counts that the picker mapping does not reflect.The native picker may offer choices that the UploadThing route rejects.Review route config and both picker constraint mappings together.
A selected asset loses its local URI before FormData sends it.React Native cannot represent the asset as an upload file.Preserve the URI on each file passed to startUpload.

Key files

FileWhy to read it
packages/…/index.tsDefines the Expo entry point, helper factory, URL resolution, and public picker helper surface.
packages/…/document-picker.tsShows the document selection path from route limits to UploadThing upload.
packages/…/image-picker.tsShows the image and video selection path, permission checks, and asset handoff.
packages/…/use-uploadthing.tsDefines the shared endpoint lookup, upload lifecycle, state, and callback behavior used by both Expo hooks.
packages/…/component-utils.tsDefines the shared conversion from route configuration to permitted file types and multi-file behavior.
packages/…/package.jsonStates the Expo, React Native, and UploadThing runtime contract for the package.