> ## Documentation Index
> Fetch the complete documentation index at: https://mediadrop.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Types

> Every shared type exported from react-mediadrop

`react-mediadrop` re-exports every shared type — there's never a reason to
import from an internal engine package directly.

## `MediaDropFile`

```ts theme={"theme":{"light":"github-light","dark":"vesper"}}
type MediaDropFile = {
	id: string;
	file: File;
	name: string;
	size: number;
	type: string;
	lastModified?: number;
	status: "idle" | "accepted" | "rejected";
	errors: MediaDropError[];

	// Upload fields, only set once an upload is requested:
	uploadStatus?: "queued" | "uploading" | "done" | "error" | "canceled";
	progress?: { loaded: number; total: number | null };
	uploadError?: MediaDropError;
	uploadResult?: unknown;
	uploadAttempts?: number;
};
```

## `MediaDropRestrictions`

```ts theme={"theme":{"light":"github-light","dark":"vesper"}}
type MediaDropRestrictions = {
	maxFiles?: number;
	minSize?: number; // bytes
	maxSize?: number; // bytes
	accept?: string[] | string; // mime types, wildcards, or extensions
};
```

## `MediaDropError`

```ts theme={"theme":{"light":"github-light","dark":"vesper"}}
type MediaDropErrorCode =
	| "file-invalid-type"
	| "file-too-large"
	| "file-too-small"
	| "too-many-files"
	| "validator-error"
	| "upload-error";

type MediaDropError = {
	code: MediaDropErrorCode;
	message: string;
	status?: number; // HTTP status, upload errors only
	sourceCode?: string; // transport-specific, upload errors only
};
```

## `MediaDropValidator`

```ts theme={"theme":{"light":"github-light","dark":"vesper"}}
type MediaDropValidator = (
	file: File,
) => MediaDropError | MediaDropError[] | null | undefined;
```

## `DragState`

```ts theme={"theme":{"light":"github-light","dark":"vesper"}}
type DragState = {
	isDragActive: boolean;
	isDragAccept: boolean;
	isDragReject: boolean;
};
```

## `UploadTransport`

```ts theme={"theme":{"light":"github-light","dark":"vesper"}}
type UploadTransport = {
	upload(
		file: MediaDropFile,
		context: {
			onProgress: (progress: { loaded: number; total: number | null }) => void;
			signal: AbortSignal;
		},
	): Promise<{ response?: unknown }>;
};
```

## `RetryOptions` and `withRetry`

```ts theme={"theme":{"light":"github-light","dark":"vesper"}}
type RetryOptions = {
	retries?: number;
	retryDelays?: number[];
	shouldRetry?: (error: unknown, attemptNumber: number) => boolean;
	jitter?: number; // 0–1
};

function withRetry<T>(
	attempt: (attemptNumber: number) => Promise<T>,
	options: RetryOptions,
	signal: AbortSignal,
): Promise<T>;
```

## Session persistence

Exported for custom resumable transports — no bundled transport currently
uses them.

```ts theme={"theme":{"light":"github-light","dark":"vesper"}}
type MediaDropUploadSessionStore = {
	get(key: string): Promise<unknown | null>;
	set(key: string, value: unknown): Promise<void>;
	remove(key: string): Promise<void>;
};

function createMemoryUploadSessionStore(): MediaDropUploadSessionStore;
function createBrowserUploadSessionStore(options?: {
	prefix?: string;
}): MediaDropUploadSessionStore;

function createFileFingerprint(file: File): string;
```

<CardGroup cols={2}>
  <Card title="Core concepts" icon="cube" href="/guides/core-concepts">
    The file model, the store, and drag state
  </Card>

  <Card title="useMediaDrop API" icon="code" href="/api-reference/use-media-drop">
    Full hook reference
  </Card>
</CardGroup>
