Back to Remotion

ensureBrowser()

packages/docs/docs/renderer/ensure-browser.mdx

4.0.4812.3 KB
Original Source

ensureBrowser()<AvailableFrom v="4.0.137" />

Ensures a browser is locally installed so a Remotion render can be executed.

tsx
import {ensureBrowser} from '@remotion/renderer';

await ensureBrowser();
tsx
import {ensureBrowser} from '@remotion/renderer';

await ensureBrowser({
  onBrowserDownload: () => {
    console.log('Downloading browser');

    return {
      version: '149.0.7790.0',
      onProgress: ({percent}) => {
        console.log(`${Math.round(percent * 100)}% downloaded`);
      },
    };
  },
});

API

An object with the following properties, all of which are optional:

chromeMode?<AvailableFrom v="4.0.248" />

<Options id="chrome-mode" />

browserExecutable?

Pass a path to a browser executable that you want to use instead of downloading.
If the path does not exist, this function will throw.
Pass the same path to any other API that supports the browserExecutable option.

logLevel?

<Options id="log" />

onBrowserDownload

Specify a specific version of Chrome that should be used and hook into the download progress.
See the example below for the function signature.

tsx
import {ensureBrowser, OnBrowserDownload, DownloadBrowserProgressFn} from '@remotion/renderer';

const onProgress: DownloadBrowserProgressFn = ({percent, downloadedBytes, totalSizeInBytes}) => {
  console.log(`${Math.round(percent * 100)}% downloaded`);
};

const onBrowserDownload: OnBrowserDownload = () => {
  console.log('Downloading browser');

  return {
    // Pass `null` to use Remotion's recommendation.
    version: '149.0.7790.0',
    onProgress,
  };
};

await ensureBrowser({
  onBrowserDownload,
});

Return value

A promise with no value.

Compatibility

<CompatibilityTable chrome={false} firefox={false} safari={false} nodejs={true} bun={true} serverlessFunctions={false} clientSideRendering={false} serverSideRendering={true} player={false} studio={false} />

See also