Skip to content

useMediaCapabilities

Returns MediaCapabilities for the active client via getCapabilities(client) from @media-sdk/core. Use this hook to gate tabs, filters, and buttons — never branch on provider name strings.

bash
pnpm add @media-sdk/core@^0.3.1 @media-sdk/native@^0.1.0 react

Must be called inside MediaProvider.

Returns

MediaCapabilities with three groups:

GroupFieldsUse for
operationssearchPhotos, searchVideos, getPhoto, getVideo, curatedPhotos, trackView, trackDownloadGate tabs, buttons, and client method calls
photoFiltersorientation, size, color, category, minWidth, minHeight, editorsChoice, localeGate photo filter UI
videoFiltersSame fields as photoFiltersGate video filter UI

Custom clients without a capabilities property receive an all-false fallback from getCapabilities.

Type export

ts
import type { MediaCapabilities } from "@media-sdk/native";

MediaCapabilities is re-exported from @media-sdk/core types via the hook module.

Example

tsx
import { useMediaCapabilities } from "@media-sdk/native";
import { View, Text, Pressable } from "react-native";

function FilterBar({
  orientation,
  onOrientationChange,
}: {
  orientation: string;
  onOrientationChange: (value: string) => void;
}) {
  const caps = useMediaCapabilities();

  return (
    <View>
      {caps.photoFilters.orientation && (
        <Pressable onPress={() => onOrientationChange("landscape")}>
          <Text>Landscape</Text>
        </Pressable>
      )}

      {caps.photoFilters.size && (
        <Pressable onPress={() => onOrientationChange("large")}>
          <Text>Large</Text>
        </Pressable>
      )}
    </View>
  );
}

Anti-pattern

Do not branch on provider identity in presentation code:

tsx
// ❌ Forbidden in tabs, filters, grids
if (provider === "pexels") {
  showCuratedTab();
}

// ✅ Required
const caps = useMediaCapabilities();
if (caps.operations.curatedPhotos) {
  showCuratedTab();
}

Provider names are acceptable in settings / selector labels and client construction only.

Provider matrix

See Pexels + Pixabay for the full capability table sourced from PexelsMediaClient.capabilities and PixabayMediaClient.capabilities.