Astro Starter Kit
Words are nice... but code speaks louder. Dive into a fully commented project template, showcasing these techniques (and more) in action.
Sorry, no results found for "".
One of the advantages of using DatoCMS instead of other content management systems is its video
query, which will return pre-computed video attributes that will help you display videos in your frontend without any additional manipulation.
Let's begin by defining our GraphQL query, which is necessary to retrieve data for the video player:
The video player will be an Astro Island, pre-rendered on the server, and then re-hydrated on the client using client directives.
The UI framework for this island can be any among React, Vue, or SvelteKit, since we have developed a <VideoPlayer />
component for each of these choices. Choose based on your personal preferences.
For the purposes of this guide, we will choose React, and therefore we will install the react-datocms
package:
npm install react-datocms
Now you can feed content coming from a video
query directly into the <VideoPlayer />
component:
---import { VideoPlayer } from '@datocms/react';
const query = `...`;
const data = await executeQuery(query);---
<VideoPlayer data={data.blogPost.coverVideo.video} client:visible />
The client:visible
prop is used to ensure that the component loads and hydrates once the component has entered the user’s viewport. However, you can choose any among the other client directives made available by Astro.