Hook for updating an existing Stream.


  • React

  • React Native

import { useUpdateStream } from '@livepeer/react';

The following example shows how an stream can be updated to enable recording and require a JWT for playback

const streamId = "abcff74a-bb19-45af-8e63-b961efa1899e";

function SomeComponent() {
  const { data: stream } = useStream({
    refetchInterval: 10000,
  const {
    mutate: updateStream,
  } = useUpdateStream({
    record: true,
    playbackPolicy: {
      type: "jwt",

  return (
        disabled={status === "loading" || stream.record || !updateStream}
        onClick={() => {
        Enable Recording
      {stream && (
          <div>Stream Name: {stream?.name}</div>
          <div>Recording?: {String(Boolean(stream.record))}</div>
      {error && <div>{error.message}</div>}

Return Value

The return value is partially based on Tanstack Query, with some return types aggregated for simplicity.

  data?: Stream,
  error?: Error,
  isError: boolean,
  isIdle: boolean,
  isLoading: boolean,
  isSuccess: boolean,
  status: 'idle' | 'loading' | 'success' | 'error',
  mutate: () => void,
  mutateAsync: () => Promise<Stream>,
  variables?: UpdateStreamArgs



The stream ID to update - required.

function SomeComponent() {
  const { mutate: createStream } = useUpdateStream({
    record: true,


Whether to immediately block ingest and playback of the stream.


Whether to create recordings of the stream sessions. Defaults to false.


The configuration for multistreaming (AKA “restream” or “simulcast”) - allows configuration of targets where this stream should be simultaneously streamed to.

The multistream targets can be either a full MultistreamTarget like on create, or a MultistreamTargetRef. The Ref object comes directly from the existing Stream object, in case multistream has already been configured for the given stream. It contains a vanity ID instead of the full Spec since the ingest URL contains user secrets like the stream key.

type MultistreamTarget = {
   * Name of transcoding profile that should be sent. Use "source" for pushing
   * source stream data
  profile: string;
   * If true, the stream audio will be muted and only silent video will be
   * pushed to the target.
  videoOnly?: boolean;
   * Unique ID of this multistream target. Used to dedup targets on update.
  id?: string;
   * Inline spec for the multistream target object. Underlying target resource
   * will be automatically created.
  spec?: {
    /** Name for the multistream target. Defaults to the URL hostname */
    name?: string;
    /** Livepeer-compatible multistream target URL (RTMP(s) or SRT) */
    url: string;


Configuration for stream playback access-control policy. Defaults to public.

type PlaybackPolicy = {
   * The type of playback policy to apply. `jwt` requires a signed JWT for
   * playback. `webhook` requires that a webhook is configured and passed during the
   * creation of the asset. `public` indicates no
   * access control will be applied (anyone with the `playbackId` can
   * view without a JWT or webhook).
  type: "webhook" | "jwt" | "public";

type WebhookPlaybackPolicy<TContext extends object> = PlaybackPolicy & {
  type: "webhook";
  /** The ID of the webhook which has already been created. */
  webhookId: string;
  /** The context which is passed to the webhook when it is called on playback. */
  webhookContext: TContext;


The mutationConfig parameter allows for any Tanstack Query useMutation options, such as cacheTime or retry. These override any configs passed by default by the internal hook.

function SomeComponent() {
  const { mutate: updateStream } = useUpdateStream({
    record: true,
    mutationConfig: { retry: 3 },