Usage
- React
- React Native
Metrics are currently only available if a user has the ID associated with an
asset. This should only be the user(s) with write access to the asset -
viewers are not able to use this hook.
Player is used for playback (with its built-in metrics
reporting).
Return Value
The return value is partially based on Tanstack Query, with some return types aggregated for simplicity.Configuration
assetId
Asset identifier.UseQueryOptions
TheuseAssetMetrics hook also supports any
Tanstack Query
useQuery options, such as refetchInterval or enabled. These override any
configs passed by default by the internal hook.
SSR
Next.js
TheuseAssetMetrics hook also comes with a
Tanstack Query prefetch query,
prefetchAssetMetrics, which makes it easy to prefetch data for server-side
rendering.
First, you add a
getStaticProps
function to the page which you want to prefetch data on. The props should match
the useAsset hook to ensure that the correct data is prefetched.
_app.tsx to pass the dehydratedState in pageProps to
the LivepeerConfig. We also move the livepeerClient into a useMemo hook so
that a new client is created on each request.
Other Frameworks
The process is very similar for other frameworks, with the exception that there is aclearClient boolean which should be used to ensure that the client cache
is not reused across users.