Hook for creating a new Stream.


  • React

  • React Native

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

The stream ID should only be passed to users who are allowed to modify the stream. Ensure viewers are only provided with the playbackId, which is a limited identifier that provides only the ability to stream media using the Player.

The following example shows how a stream can be created.

const streamName = `New Stream`;

function SomeComponent() {
  const {
    mutate: createStream,
    data: stream,
  } = useCreateStream({ name: streamName });

  return (
        disabled={status === "loading" || !createStream}
        onClick={() => createStream?.()}
        Create Stream
      {stream && <div>Stream Key: {stream.streamKey}</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?: CreateStreamArgs



The name for the new stream. Required to create a stream.

function SomeComponent() {
  const { mutate: createStream } = useCreateStream({
    name: "My new stream",


Transcoding profiles to use for the stream for ABR playback. When this is not defined, the defaultTranscodingProfiles are used (720p, 480p, and 360p).


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.


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: createStream } = useCreateStream({
    name: "My new stream",
    mutationConfig: { retry: 3 },