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
Prop | Type | Default | Description |
---|---|---|---|
publicKey | string | Required | Your easyCDN public API key |
acceptedFileTypes | string[] | undefined | Array of accepted MIME types or extensions |
maxSize | number | 1000 * 1000 * 1000 * 15 | Maximum file size in bytes (15GB default) |
maxFiles | number | 10 | Maximum number of files allowed |
showPreview | boolean | false | Show image previews in file list |
darkMode | boolean | false | Enable dark theme |
compact | boolean | false | Use compact file list layout |
clearAfter | number | 5000 | Auto-clear completed uploads after milliseconds |
maxRetries | number | 3 | Maximum retry attempts for failed uploads |
baseUrl | string | api.easyCDN.co | Custom API endpoint URL |
className | string | undefined | Additional CSS classes |
projectId | string | undefined | Optional 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