UploadKit
SDK@uploadkitdev/react

API Reference

Complete API reference for @uploadkitdev/react — all components, hooks, and types.

UploadKitProvider

Context provider. Wrap your app (or upload UI) with this to make the SDK client available to all child components and hooks.

function UploadKitProvider(props: UploadKitProviderProps): JSX.Element

UploadKitProviderProps

PropTypeRequiredDescription
endpointstringYesThe local API route that proxies requests to the UploadKit API. Example: "/api/uploadkit". Your UPLOADKIT_API_KEY is held server-side in this route — never passed to the browser.
childrenReactNodeYesComponent tree with access to upload functionality.

useUploadKit

Headless upload state machine hook. Must be used inside <UploadKitProvider>.

function useUploadKit(route: string): {
  upload: (file: File, metadata?: Record<string, unknown>) => Promise<void>;
  abort: () => void;
  reset: () => void;
  status: 'idle' | 'uploading' | 'success' | 'error';
  progress: number;
  error: Error | null;
  result: UploadResult | null;
  isUploading: boolean;
}
ReturnTypeDescription
upload(file: File, metadata?) => Promise<void>Upload a file. Aborts any existing in-progress upload first.
abort() => voidCancel the current upload and reset to idle.
reset() => voidReset state to idle.
status'idle' | 'uploading' | 'success' | 'error'Current upload lifecycle state.
progressnumberProgress percentage (0–100).
errorError | nullLast error. Null when not in error state.
resultUploadResult | nullLast upload result. Null when not in success state.
isUploadingbooleanstatus === 'uploading'.

UploadButton

const UploadButton: React.ForwardRefExoticComponent<UploadButtonProps & React.RefAttributes<HTMLButtonElement>>

UploadButtonProps

PropTypeDefaultDescription
routestringRequired. Route name from the file router.
acceptstring[]MIME types for the file input.
maxSizenumberMax file size in bytes (client-side validation).
metadataRecord<string, unknown>Metadata forwarded to the server.
onUploadComplete(result: UploadResult) => voidCalled after successful upload.
onUploadError(error: Error) => voidCalled on upload failure.
variant'default' | 'outline' | 'ghost''default'Visual style variant.
size'sm' | 'md' | 'lg''md'Size variant.
disabledbooleanfalseDisables the button.
classNamestringCSS class(es) for the outer wrapper.
appearancePartial<Record<'button' | 'progressBar' | 'progressText', string>>CSS class overrides for inner elements.
config{ mode?: 'auto' | 'manual' }{ mode: 'auto' }Controls when the upload begins after file selection. auto uploads immediately; manual stages files for user confirmation.
onBeforeUploadBegin(files: File[]) => File[] | Promise<File[]>Transform or filter files before upload. Return empty array to cancel.
uploadProgressGranularity'coarse' | 'fine' | 'all''coarse'How frequently onUploadProgress is called during upload.
childrenReactNodeCustom button label.

UploadDropzone

const UploadDropzone: React.ForwardRefExoticComponent<UploadDropzoneProps & React.RefAttributes<HTMLDivElement>>

UploadDropzoneProps

PropTypeDefaultDescription
routestringRequired. Route name from the file router.
acceptstring[]MIME types. Wildcards supported: 'image/*'.
maxSizenumberMax file size in bytes (client-side validation).
maxFilesnumberMax number of files per drop or selection.
metadataRecord<string, unknown>Metadata forwarded to the server.
onUploadComplete(results: UploadResult[]) => voidCalled after all files upload successfully.
onUploadError(error: Error) => voidCalled when any file upload fails.
disabledbooleanfalseDisables the dropzone.
classNamestringCSS class(es) for the outer wrapper.
config{ mode?: 'auto' | 'manual' }{ mode: 'manual' }Controls when the upload begins after file selection. manual stages files with a confirm button; auto uploads immediately on drop or selection.
onBeforeUploadBegin(files: File[]) => File[] | Promise<File[]>Transform or filter files before upload. Return empty array to cancel.
uploadProgressGranularity'coarse' | 'fine' | 'all''coarse'How frequently onUploadProgress is called during upload.
appearancePartial<Record<'container' | 'label' | 'icon' | 'fileItem' | 'progressBar' | 'button', string>>CSS class overrides for inner elements.

UploadDropzoneGlass

const UploadDropzoneGlass: React.ForwardRefExoticComponent<UploadDropzoneGlassProps & React.RefAttributes<HTMLDivElement>>

Premium variant inspired by Vercel and Linear. Frosted glass, hairline borders, indigo glow halo on drag-over. See UploadDropzoneGlass for the full guide.

UploadDropzoneGlassProps

PropTypeDefaultDescription
routestringRequired. Route name from the file router.
acceptstring[]MIME types. Wildcards supported.
maxSizenumberMax file size in bytes.
maxFilesnumberMax number of files per drop.
metadataRecord<string, unknown>Metadata forwarded to the server.
onUploadComplete(results: UploadResult[]) => voidCalled after all files upload.
onUploadError(error: Error) => voidCalled once per failed file.
disabledbooleanfalseDisables drag, click, and the file input.
classNamestringCSS class(es) for the outer wrapper.
childrenReactNodeCustom heading.

UploadDropzoneAurora

const UploadDropzoneAurora: React.ForwardRefExoticComponent<UploadDropzoneAuroraProps & React.RefAttributes<HTMLDivElement>>

Animated conic-gradient mesh with a cursor-follow specular highlight. See UploadDropzoneAurora.

UploadDropzoneAuroraProps

Same shape as UploadDropzoneGlassProps (route, accept, maxSize, maxFiles, metadata, onUploadComplete, onUploadError, disabled, className, children).


UploadDropzoneTerminal

const UploadDropzoneTerminal: React.ForwardRefExoticComponent<UploadDropzoneTerminalProps & React.RefAttributes<HTMLDivElement>>

Monospace terminal-style dropzone with a blinking cursor and tail-style log. See UploadDropzoneTerminal.

UploadDropzoneTerminalProps

Same shape as UploadDropzoneGlassProps.


UploadDropzoneBrutal

const UploadDropzoneBrutal: React.ForwardRefExoticComponent<UploadDropzoneBrutalProps & React.RefAttributes<HTMLDivElement>>

Neobrutalist dropzone with thick borders, a hard shadow offset, and a stamp-down animation. See UploadDropzoneBrutal.

UploadDropzoneBrutalProps

Same shape as UploadDropzoneGlassProps.


UploadButtonShimmer

const UploadButtonShimmer: React.ForwardRefExoticComponent<UploadButtonShimmerProps & React.RefAttributes<HTMLButtonElement>>

CTA upload button with a shimmer sweep and indigo glow on hover. See UploadButtonShimmer.

UploadButtonShimmerProps

PropTypeDefaultDescription
routestringRequired. Route name from the file router.
acceptstring[]MIME types for the file input.
maxSizenumberMax file size in bytes.
metadataRecord<string, unknown>Metadata forwarded to the server.
onUploadComplete(result: UploadResult) => voidCalled after successful upload.
onUploadError(error: Error) => voidCalled on upload failure.
disabledbooleanfalseDisables the button.
classNamestringCSS class(es) for the button.
childrenReactNodeCustom label.

UploadButtonMagnetic

const UploadButtonMagnetic: React.ForwardRefExoticComponent<UploadButtonMagneticProps & React.RefAttributes<HTMLButtonElement>>

Pill-shaped upload button that attracts toward the cursor with a Motion spring. See UploadButtonMagnetic.

UploadButtonMagneticProps

Same shape as UploadButtonShimmerProps.


UploadAvatar

const UploadAvatar: React.ForwardRefExoticComponent<UploadAvatarProps & React.RefAttributes<HTMLDivElement>>

Circular avatar uploader with blur-up preview and an SVG progress ring. See UploadAvatar.

UploadAvatarProps

PropTypeDefaultDescription
routestringRequired. Route name from the file router.
acceptstring[]['image/*']MIME types.
maxSizenumberMax file size in bytes.
metadataRecord<string, unknown>Metadata forwarded to the server.
initialSrcstringInitial avatar image URL.
sizenumber96Width and height in pixels.
onUploadComplete(result: UploadResult) => voidCalled after successful upload.
onUploadError(error: Error) => voidCalled on upload failure.
classNamestringCSS class(es) for the outer wrapper.

UploadInlineChat

const UploadInlineChat: React.ForwardRefExoticComponent<UploadInlineChatProps & React.RefAttributes<HTMLDivElement>>

ChatGPT-style composer with a paperclip attach button and animated file chips. See UploadInlineChat.

UploadInlineChatProps

PropTypeDefaultDescription
routestringRequired. Route name from the file router.
acceptstring[]MIME types. Wildcards supported.
maxSizenumberMax file size in bytes.
maxFilesnumberMax number of files per selection.
metadataRecord<string, unknown>Metadata forwarded to the server.
onUploadComplete(results: UploadResult[]) => voidCalled after all files upload.
onUploadError(error: Error) => voidCalled once per failed file.
placeholderstring'Send a message...'Placeholder for the message field.
classNamestringCSS class(es) for the outer wrapper.

All eight premium variants above depend on motion as an optional peerDependency. Without it they render a static fallback; install it with pnpm add motion to enable the full animation set.


Motion & Progress variants

Eight motion-forward upload affordances shipped in quick task 260410-kw3. All use CSS custom properties for theming, respect prefers-reduced-motion, and expose full ARIA progress semantics.

UploadProgressRadial

const UploadProgressRadial: React.ForwardRefExoticComponent<UploadProgressRadialProps & React.RefAttributes<HTMLDivElement>>

Activity-ring style radial progress with pathLength fill and a success splash. See UploadProgressRadial.

UploadProgressRadialProps

PropTypeDefaultDescription
routestringRequired. Route name from the file router.
acceptstring[]MIME types.
maxSizenumberMax file size in bytes.
metadataRecord<string, unknown>Metadata forwarded to the server.
sizenumber120Diameter of the ring in pixels.
strokeWidthnumber6Ring stroke width.
labelstring'Upload'Center label when idle.
onUploadComplete(result: UploadResult) => voidCalled after successful upload.
onUploadError(error: Error) => voidCalled on upload failure.
classNamestringCSS class(es) for the outer wrapper.

UploadProgressBar

const UploadProgressBar: React.ForwardRefExoticComponent<UploadProgressBarProps & React.RefAttributes<HTMLDivElement>>

Horizontal progress bar with shimmer sweep, indeterminate state, and a bounce-check on success. See UploadProgressBar.

UploadProgressBarProps

PropTypeDefaultDescription
routestringRequired.
acceptstring[]MIME types.
maxSizenumberMax file size in bytes.
metadataRecord<string, unknown>Forwarded metadata.
indeterminatebooleanfalseForce indeterminate sliding state.
showPercentbooleantrueShow percent label.
buttonLabelstring'Select file'CTA label.
onUploadComplete(result: UploadResult) => voidSuccess callback.
onUploadError(error: Error) => voidFailure callback.
classNamestringCSS class(es).

UploadProgressStacked

const UploadProgressStacked: React.ForwardRefExoticComponent<UploadProgressStackedProps & React.RefAttributes<HTMLDivElement>>

Multi-file vertical progress list where completed rows float to the top. Inspired by iOS AirDrop. See UploadProgressStacked.

UploadProgressStackedProps

Same shape as UploadDropzoneGlassProps (route, accept, maxSize, maxFiles, metadata, onUploadComplete, onUploadError, className, children).


UploadProgressOrbit

const UploadProgressOrbit: React.ForwardRefExoticComponent<UploadProgressOrbitProps & React.RefAttributes<HTMLDivElement>>

Circular orbit of satellites that collapse to the center as each upload completes. See UploadProgressOrbit.

UploadProgressOrbitProps

Same shape as UploadProgressStackedProps, plus radius?: number (default 80).


UploadCloudRain

const UploadCloudRain: React.ForwardRefExoticComponent<UploadCloudRainProps & React.RefAttributes<HTMLDivElement>>

Cloud icon that fills as progress advances, with droplets raining down as files are picked. See UploadCloudRain.

UploadCloudRainProps

Same shape as UploadProgressStackedProps.


UploadBento

const UploadBento: React.ForwardRefExoticComponent<UploadBentoProps & React.RefAttributes<HTMLDivElement>>

CSS grid bento layout — every third cell spans 2 columns. Inspired by Apple iPadOS widgets. See UploadBento.

UploadBentoProps

Same shape as UploadProgressStackedProps (minus children), plus columns?: number (default 3).


UploadParticles

const UploadParticles: React.ForwardRefExoticComponent<UploadParticlesProps & React.RefAttributes<HTMLDivElement>>

Constellation of particles converging to the center as upload progress advances. Pure CSS transforms. See UploadParticles.

UploadParticlesProps

Same shape as UploadProgressStackedProps (minus children), plus particleCount?: number (default 40).


UploadStepWizard

const UploadStepWizard: React.ForwardRefExoticComponent<UploadStepWizardProps & React.RefAttributes<HTMLDivElement>>

5-stage single-file upload wizard (select → preview → confirm → upload → done). See UploadStepWizard.

UploadStepWizardProps

Same shape as UploadAvatarProps (minus accept default, initialSrc, size).

All eight motion & progress variants use CSS fallbacks for their animations — motion is only required for the smooth layout reorders in UploadProgressStacked and UploadBento, and the AnimatePresence-driven transitions in UploadStepWizard.


UploadModal

function UploadModal(props: UploadModalProps): JSX.Element

UploadModalProps

PropTypeDefaultDescription
openbooleanRequired. Controls modal visibility.
onClose() => voidRequired. Called on ESC or backdrop click.
routestringRequired. Route name from the file router.
acceptstring[]Accepted MIME types.
maxSizenumberMax file size in bytes.
maxFilesnumberMax number of files.
metadataRecord<string, unknown>Metadata forwarded to the server.
onUploadComplete(results: UploadResult[]) => voidCalled after all files upload successfully.
onUploadError(error: Error) => voidCalled when any upload fails.
classNamestringCSS class(es) for the <dialog> element.
titlestringHeading text and aria-label for the dialog.
appearancePartial<Record<'modal' | 'backdrop' | 'content' | 'container' | 'label' | 'icon' | 'fileItem' | 'progressBar' | 'button', string>>CSS class overrides for inner elements.

FileList

function FileList(props: FileListProps): JSX.Element

FileListProps

PropTypeRequiredDescription
filesUploadResult[]YesArray of upload results to display.
onDelete(fileKey: string) => voidNoDelete button handler. Hidden when not provided.
classNamestringNoCSS class(es) for the list wrapper.
appearancePartial<Record<'list' | 'item' | 'preview' | 'name' | 'size' | 'deleteButton', string>>NoCSS class overrides for inner elements.

FilePreview

function FilePreview(props: FilePreviewProps): JSX.Element

FilePreviewProps

PropTypeRequiredDescription
fileFile | UploadResultYesFile to preview.
classNamestringNoCSS class(es) for the container.
appearancePartial<Record<'container' | 'image' | 'icon', string>>NoCSS class overrides.

useDragState

Hook for drag-and-drop state management. Uses an integer counter (not boolean) to prevent flickering on child element drag events.

function useDragState(
  onDrop: (files: File[]) => void
): {
  isDragging: boolean;
  handlers: {
    onDragEnter: (e: React.DragEvent) => void;
    onDragLeave: (e: React.DragEvent) => void;
    onDragOver: (e: React.DragEvent) => void;
    onDrop: (e: React.DragEvent) => void;
  };
}

useAutoDismiss

Hook that manages a list of items with auto-removal after a delay.

function useAutoDismiss<T extends { id: string }>(
  delay: number
): [items: T[], add: (item: T) => void, remove: (id: string) => void]

useThumbnail

Hook that generates a thumbnail URL for a File using URL.createObjectURL (images) or canvas frame capture (videos). Defers generation until the container is visible using IntersectionObserver.

function useThumbnail(
  file: File,
  containerRef: React.RefObject<HTMLElement | null>
): {
  thumbnailUrl: string | null;
  isGenerating: boolean;
}

generateReactHelpers

Type-safe factory that narrows the route prop to the literal keys of your file router.

function generateReactHelpers<TRouter extends FileRouter>(): {
  UploadButton: React.ComponentType<Omit<UploadButtonProps, 'route'> & { route: keyof TRouter & string }>;
  UploadDropzone: React.ComponentType<Omit<UploadDropzoneProps, 'route'> & { route: keyof TRouter & string }>;
  UploadModal: React.ComponentType<Omit<UploadModalProps, 'route'> & { route: keyof TRouter & string }>;
  useUploadKit: (route: keyof TRouter & string) => ReturnType<typeof useUploadKit>;
}

Usage:

import { generateReactHelpers } from '@uploadkitdev/react';
import type { AppFileRouter } from '@/app/api/uploadkit/[...uploadkit]/route';

export const { UploadButton, UploadDropzone, UploadModal, useUploadKit } =
  generateReactHelpers<AppFileRouter>();

CSS custom properties

See the full Theming reference for all CSS variables, their defaults in light and dark mode, and what they control.

VariableLightDarkControls
--uk-primary#0070f3#0070f3Buttons, borders, focus rings
--uk-primary-hover#005bb5#005bb5Hover states
--uk-bg#ffffff#0a0a0bComponent backgrounds
--uk-bg-secondary#fafafa#141416Secondary backgrounds
--uk-border#eaeaeargba(255,255,255,0.08)Borders
--uk-text#171717#fafafaPrimary text
--uk-text-secondary#666666#a1a1aaSecondary text
--uk-success#00c853#00c853Success states
--uk-error#dc2626#dc2626Error states
--uk-radius12px12pxBorder radius
--uk-fontSystem UISystem UIFont family
--uk-transition200ms ease-out200ms ease-outTransitions

VERSION

import { VERSION } from '@uploadkitdev/react';
// '0.1.0'

On this page