Back to Remotion

getRemotionEnvironment()

packages/docs/docs/get-remotion-environment.mdx

4.0.4622.4 KB
Original Source

getRemotionEnvironment()<AvailableFrom v="4.0.25" />

With the getRemotionEnvironment() function, you can retrieve information about the current Remotion Environment.

:::info Consider using the useRemotionEnvironment() hook instead, as it is future-proof for browser rendering scenarios. ::: It returns an object with the following properties:

This can be useful if you want components or functions to behave differently depending on the environment.

Example

tsx
import React from 'react';
import {getRemotionEnvironment} from 'remotion';

export const MyComp: React.FC = () => {
  const {isStudio, isPlayer, isRendering} = getRemotionEnvironment();

  if (isStudio) {
    return <div>I'm in the Studio!</div>;
  }

  if (isPlayer) {
    return <div>I'm in the Player!</div>;
  }

  if (isRendering) {
    return <div>I'm Rendering</div>;
  }

  return <div>Hello World!</div>;
};

A more realistic use case: You might want to debounce a request during editing in the Remotion Studio, but not during rendering. See: debouncing requests

Compatibility

<CompatibilityTable chrome firefox safari nodejs="All false" bun="All false" serverlessFunctions="All false" clientSideRendering="Use useRemotionEnvironment()" serverSideRendering player studio />

See also