function launch
launch(
config: LaunchTarget,
skipPrelaunch?: boolean
): Promise<Browser>

Launches a browser for the given config.browser type. For chromium: connects via CDP to the pre-launched Chrome (fast path) or falls back to chromium.launch() if pre-launch failed. For firefox/webkit: uses playwright's standard launch (requires npx playwright install [browser]).

import * as Browser from './browser.ts';

import type { Config } from '../types.ts';

// Defined, not invoked: connects to / launches a real browser.
async function example(config: Config) {
  const browser = await Browser.launch(config); // chromium: CDP fast path, else playwright launch()
  return browser.newPage();
}

Parameters

optional
skipPrelaunch: boolean = false

When true, bypasses the prelaunch CDP path entirely and goes straight to a fresh chromium.launch(). Used by the daemon's crash-recovery path — prelaunch is a one-shot startup optimization and recovery needs a fresh browser.

Return Type

Promise<Browser>

Usage

import { launch } from "lib/setup/browser.ts";