Native filters
Native hooks forward filter objects from @media-sdk/core unchanged — same types and validation as web.
bash
pnpm add @media-sdk/core@^0.3.1 @media-sdk/native@^0.1.0 reactHook forwarding
useMediaSearchacceptsphotoFilters→client.searchPhotos({ ...params, photoFilters })useMediaVideosacceptsvideoFilters→client.searchVideos({ ...params, videoFilters })
Changing filters triggers a new search (prior request is aborted).
PhotoSearchFilters / VideoSearchFilters
ts
interface PhotoSearchFilters {
orientation?: "landscape" | "portrait" | "square";
size?: "large" | "medium" | "small";
color?: PhotoColor | PixabayColor;
category?: string;
minWidth?: number;
minHeight?: number;
editorsChoice?: boolean;
locale?: string;
}VideoSearchFilters uses the same shape.
Capability-gated filter UI
Build filter controls only when the active provider supports them:
tsx
import { useMediaCapabilities, useMediaSearch } from "@media-sdk/native";
function SearchWithFilters({ query }: { query: string }) {
const caps = useMediaCapabilities();
const [orientation, setOrientation] = useState<"landscape" | "portrait">("landscape");
const { data, loading } = useMediaSearch({
query,
photoFilters: caps.photoFilters.orientation
? { orientation }
: undefined,
});
// render filters + results
}Filter UI components are not included in @media-sdk/ui-native v0.1.0 — use Picker, segmented controls, or custom buttons in your app. The Expo example demonstrates orientation and size filters.
Error handling
| Code | Cause |
|---|---|
UNSUPPORTED_FILTER | Filter field not supported by active provider |
INVALID_FILTER_VALUE | Value rejected by provider (e.g. unsupported color) |
Catch MediaError from hook error state or wrap custom client calls. See Error handling recipes and Core errors.
Provider filter matrix
| Filter | Pexels photos | Pexels videos | Pixabay photos | Pixabay videos |
|---|---|---|---|---|
orientation | ✅ | ✅ | ✅ | ❌ |
size | ✅ | ✅ | ❌ | ❌ |
color | ✅ | ❌ | ✅ | ❌ |
category | ❌ | ❌ | ✅ | ✅ |
minWidth / minHeight | ❌ | ❌ | ✅ | ✅ |
editorsChoice | ❌ | ❌ | ✅ | ✅ |
locale | ✅ | ✅ | ✅ | ❌ |
Sourced from PexelsMediaClient.capabilities and PixabayMediaClient.capabilities in @media-sdk/core.
Related
- Core filters — validation rules and wire mapping
- Capabilities —
useMediaCapabilities - Provider comparison — operations matrix