Skip to main content

openBrowser()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.

const openBrowser: (
  browser: 'chrome',
  options?: {
    logLevel?: LogLevel;
    browserExecutable?: string | null;
    chromiumOptions?: ChromiumOptions;
    chromeMode?: ChromeMode;
    forceDeviceScaleFactor?: number;
  },
) => Promise<HeadlessBrowser>;

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

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

If set to true, logs and other browser diagnostics are being printed to standard output. This setting is useful for debugging.

logLevel?v4.0.189​

One of trace, verbose, info, warn, error.
Determines how much info is being logged to the console.

Default info.

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.

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().

flags?v4.0.543​
Adds, replaces, or removes Chrome flags. Keys omit the leading --. true adds a bare flag, a string sets its value, and false removes it. Overrides take precedence over other Chromium options. The user-data-dir and remote-debugging-* flags are reserved. Defaults to {}. Remotion’s default Chrome flags and enabled or disabled features may change between patch versions. There is no guarantee that these defaults remain unchanged.
features?v4.0.543​
Overrides individual Chrome features. true enables a feature and removes it from the disabled list; false disables it and removes it from the enabled list. Unspecified features retain their defaults. Applied after raw flag overrides. Defaults to {}. Remotion’s default Chrome flags and enabled or disabled features may change between patch versions. There is no guarantee that these defaults remain unchanged.
blinkFeatures?v4.0.543​
Overrides individual Blink features. true enables a feature and removes it from the disabled list; false disables it and removes it from the enabled list. Unspecified features retain their defaults. Applied after raw flag overrides. Defaults to {}. Remotion’s default Chrome flags and enabled or disabled features may change between patch versions. There is no guarantee that these defaults remain unchanged.

forceDeviceScaleFactor?​

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

chromeMode?v4.0.248​

One of headless-shell, chrome-for-testing. Default headless-shell. Use chrome-for-testing to take advantage of GPU drivers on Linux.

Closing the browser​

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

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​

BrowsersServersEnvironments
Chrome
Firefox
Safari
Node.js
Bun
Serverless Functions

See also​