Skip to main content

ExternalVideo

The ExternalVideo component renders an embedded video for the Storefront API's ExternalVideo object.

The component outputs an <iframe> element. You can customize this component using passthrough props.

Example code

import {ExternalVideo, gql} from '@shopify/hydrogen';

const QUERY = gql`
query Products {
products(first: 5) {
edges {
node {
id
title
handle
media(first: 1) {
edges {
node {
... on ExternalVideo {
id
embedUrl
}
}
}
}
}
}
}
}
`;

export default function MyProductVideo() {
const {data} = useShopQuery({query: QUERY});

const firstMediaElement = data.products.edges[0].node.media.edges[0].node;
if (firstMediaElement.mediaContentType === 'EXTERNAL_VIDEO') {
return <ExternalVideo data={firstMediaElement} />;
}
}

Props

NameTypeDescription
dataPartialDeep&#60;ExternalVideoType&#62;An object with fields that correspond to the Storefront API's ExternalVideo object.
options?YouTube &#124; VimeoAn object containing the options available for either YouTube or Vimeo.
frameBorderRefer to the MDN Documentation for more information.Defaults to '0'.
allowRefer to the MDN Documentation for more information.Defaults to 'accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture'.
allowFullScreenRefer to the MDN Documentation for more information.Defaults to 'true'.
loadingRefer to the MDN Documentation for more information.Defaults to 'lazy'.

Required fields

The ExternalVideo component requires the following field from the Storefront API's ExternalVideo object:

{
embedUrl
}

Component type

The ExternalVideo component is a shared component, which means that it renders on both the server and the client. For more information about component types, refer to React Server Components.