Videocomponent
The Video
component renders a video for the Storefront API's Video object.
The component outputs a video
element. You can customize this component using passthrough props.
Anchor to propsProps
- Anchor to datadataPartialDeep<VideoType, {recurseIntoArrays: true}>required
An object with fields that correspond to the Storefront API's Video object.
- Anchor to previewImageOptionspreviewImageOptionsLoaderParams
An object of image size options for the video's
. Uses
to generate the
poster
URL.- Anchor to sourcePropssourcePropsHTMLAttributes<HTMLSourceElement> & { 'data-testid'?: string; }
Props that will be passed to the
video
element'ssource
children elements.
VideoProps
- data
An object with fields that correspond to the Storefront API's [Video object](https://shopify.dev/api/storefront/2025-01/objects/video).
PartialDeep<VideoType, {recurseIntoArrays: true}>
- previewImageOptions
An object of image size options for the video's `previewImage`. Uses `shopifyImageLoader` to generate the `poster` URL.
LoaderParams
- sourceProps
Props that will be passed to the `video` element's `source` children elements.
HTMLAttributes<HTMLSourceElement> & { 'data-testid'?: string; }
export interface VideoProps {
/** An object with fields that correspond to the Storefront API's [Video object](https://shopify.dev/api/storefront/2025-01/objects/video). */
data: PartialDeep<VideoType, {recurseIntoArrays: true}>;
/** An object of image size options for the video's `previewImage`. Uses `shopifyImageLoader` to generate the `poster` URL. */
previewImageOptions?: Parameters<typeof shopifyLoader>[0];
/** Props that will be passed to the `video` element's `source` children elements. */
sourceProps?: HTMLAttributes<HTMLSourceElement> & {
'data-testid'?: string;
};
}
LoaderParams
- crop
The URL param that controls the cropping region
Crop
- height
The URL param that controls height
number
- src
The base URL of the image
string
- width
The URL param that controls width
number
{
/** The base URL of the image */
src?: ImageType['url'];
/** The URL param that controls width */
width?: number;
/** The URL param that controls height */
height?: number;
/** The URL param that controls the cropping region */
crop?: Crop;
}
Crop
'center' | 'top' | 'bottom' | 'left' | 'right'
Example code
examples
Example code
description
I am the default example
JavaScript
import {Video} from '@shopify/hydrogen-react'; export default function MyProductVideo({products}) { const firstMediaElement = products.edges[0].node.media.edges[0].node; if (firstMediaElement.__typename === 'Video') { return <Video data={firstMediaElement} />; } }
TypeScript
import {Video} from '@shopify/hydrogen-react'; import type {ProductConnection} from '@shopify/hydrogen-react/storefront-api-types'; export default function MyProductVideo({ products, }: { products: ProductConnection; }) { const firstMediaElement = products.edges[0].node.media.edges[0].node; if (firstMediaElement.__typename === 'Video') { return <Video data={firstMediaElement} />; } }