Back to Remotion

openBrowser()

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

4.0.4672.9 KB
Original Source

Available since v3.0 - Part of the @remotion/renderer package.

Opens a Chrome or Chromium browser instance. By reusing an instance across renderFrames(), renderStill(), renderMedia() and getCompositions() calls, you can save time by not opening and closing browsers for each call.

ts
const openBrowser: (
  browser: Browser,
  options: {
    shouldDumpIo?: boolean;
    browserExecutable?: string | null;
    chromiumOptions?: ChromiumOptions;
  },
) => Promise<puppeteer.Browser>;

Arguments

browser

Currently the only valid option is "chrome". This field is reserved for future compatibility with other browsers.

options?

An object containing one or more of the following options:

shouldDumpIo?

Deprecated since v4.0.189, scheduled for removal in v5.0.

If set to true, logs and other browser diagnostics are being printed to standard output. This setting is useful for debugging.
Will be removed in 5.0: Use logLevel instead.

logLevel?<AvailableFrom v="4.0.189"/>

<Options id="log" />

browserExecutable?

A string defining the absolute path on disk of the browser executable that should be used. By default Remotion will try to detect it automatically and download one if none is available. If puppeteerInstance is defined, it will take precedence over browserExecutable.

chromiumOptions?

Allows you to set certain Chromium / Google Chrome flags. See: Chromium flags.

:::note Chromium flags need to be set at browser launch. If you pass an instance to SSR APIs like renderMedia(), the chromiumOptions option of that API will not apply, but rather the flags that have been passed to openBrowser(). :::

forceDeviceScaleFactor?

Set a scale. If you plan to use scaling, you already need to set it when opening the browser.

onBrowserDownload?<AvailableFrom v="4.0.137" />

<Options id="on-browser-download" />

chromeMode?<AvailableFrom v="4.0.248" />

<Options id="chrome-mode" />

Closing the browser

Use the close() method to cleanup a browser you are not using anymore:

ts
const browser = await openBrowser('chrome');
browser.close({silent: true});

If already closed or an operation is interrupted, an error is thrown.
Setting the silent option to true will close the browser without generating an error.

Compatibility

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

See also