Skip to main content

ensureBrowser()v4.0.137

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

Simple usage
import {ensureBrowser} from '@remotion/renderer'; await ensureBrowser();
Setting a specific Chrome version and listening to progress
import {ensureBrowser} from '@remotion/renderer'; await ensureBrowser({ onBrowserDownload: () => { console.log('Downloading browser'); return { version: '157.0.8080.0', onProgress: ({percent}) => { console.log(`${Math.round(percent * 100)}% downloaded`); }, }; }, });

API​

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

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.

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?​

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

Default info.

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.

Remotion only calls this function if the Chrome Headless Shell version that your Remotion version uses by default is not installed. If that version is already installed, the version you return is ignored.
If you use a custom version, pass the same onBrowserDownload function to every API that accepts it, such as renderMedia() and selectComposition(). Otherwise, the next call deletes the custom version and downloads Remotion's default version.

init.ts
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: '157.0.8080.0', onProgress, }; }; await ensureBrowser({ onBrowserDownload, });

Return value​

A promise resolving to an object describing the browser that is now available. Its type field is "user-defined-path" if a browserExecutable was passed, otherwise "local-puppeteer-browser". Both include the path of the executable.

Compatibility​

BrowsersServersEnvironments
Chrome
Firefox
Safari
Node.js
Bun
Serverless Functions

See also​