Skip to content

useMediaVideos

Search videos with automatic fetching, pagination, race protection, and abort handling. Same contract as useMediaSearch, but calls client.searchVideos.

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

Must be called inside MediaProvider.

Options

Extends SearchParams from @media-sdk/core plus enabled:

OptionTypeDefaultDescription
querystringRequired. Search query
pagenumber1Initial page only
perPagenumberProvider defaultResults per page
enabledbooleantrueWhen false, skips automatic fetch
videoFiltersVideoSearchFiltersForwarded to client.searchVideos unchanged

Gate filter UI with useMediaCapabilities().videoFilters before passing values.

VideoSearchFilters

Same shape as PhotoSearchFilters:

ts
interface VideoSearchFilters {
  orientation?: "landscape" | "portrait" | "square";
  size?: "large" | "medium" | "small";
  color?: PhotoColor | PixabayColor;
  category?: string;
  minWidth?: number;
  minHeight?: number;
  editorsChoice?: boolean;
  locale?: string;
}

Provider support differs — see the provider matrix.

Returns

FieldTypeDescription
dataPaginatedResponse<Video> | nullSearch results, or null before the first successful response
loadingbooleantrue while a request is in flight
errorError | nullLast non-abort error
search() => Promise<void>Manually trigger a search
nextPage() => Promise<void>Next page when hasNext is true
previousPage() => Promise<void>Previous page when hasPrevious is true
refetch() => Promise<void>Re-run search for the current page

Type export

ts
import type {
  UseMediaVideosOptions,
  UseMediaVideosResult,
} from "@media-sdk/native";

Example

tsx
import { useMediaVideos } from "@media-sdk/native";
import { Text, View } from "react-native";
import { VideoGrid } from "@media-sdk/ui-native";

function VideoSearch({ query }: { query: string }) {
  const { data, loading, error, nextPage, previousPage } = useMediaVideos({
    query,
    perPage: 15,
    videoFilters: { orientation: "landscape" },
  });

  if (loading) return <Text>Loading videos…</Text>;
  if (error) return <Text>{error.message}</Text>;

  return (
    <View>
      <VideoGrid
        videos={data?.items ?? []}
        onVideoSelect={() => {}}
      />
    </View>
  );
}

Gate the Videos tab with useMediaCapabilities().operations.searchVideos.