React SDK API Reference

Complete API reference for the easyCDN React SDK, including all components, props, and TypeScript types.

Dropzone

The main file upload component with drag-and-drop functionality.

tsx
import { Dropzone } from '@easycdn/react'

<Dropzone
  publicKey="your-public-key"
  onUploadComplete={({ tempId, previewUrl, expiresAt }) => {
    // Handle upload completion, usually persist via backend
  }}
/>

Props

PropTypeDefaultDescription
publicKeystringRequiredYour easyCDN public API key
acceptedFileTypesstring[]undefinedArray of accepted MIME types or extensions
maxSizenumber1000 * 1000 * 1000 * 15Maximum file size in bytes (15GB default)
maxFilesnumber10Maximum number of files allowed
showPreviewbooleanfalseShow image previews in file list
darkModebooleanfalseEnable dark theme
compactbooleanfalseUse compact file list layout
clearAfternumber5000Auto-clear completed uploads after milliseconds
maxRetriesnumber3Maximum retry attempts for failed uploads
baseUrlstringapi.easyCDN.coCustom API endpoint URL
classNamestringundefinedAdditional CSS classes
projectIdstringundefinedOptional project ID for multi-project setups, usually not needed.

Callbacks

onUploadComplete

Called when a single file upload completes successfully.

typescript
onUploadComplete?: (
  uploadResult: {
    tempId: string        // Temporary file ID
    previewUrl: string    // Preview URL to uploaded file (not persisted yet)
    expiresAt: Date       // When the temp file expires
  },
  file?: File             // Original File object
) => void
onAllUploadsComplete

Called when all queued uploads have finished (success or error).

typescript
onAllUploadsComplete?: () => void