Skip to content

Node.js API

const { launch, BrimpError } = require('@brimp/brimp')

The Node binding is an asynchronous, in-process native addon.

launch(options?: { personaJson?: string }): Promise<Browser>

Creates a browser backed by the shared runtime. personaJson is JSON text using Brimp’s versioned persona schema.

newPage(): Promise<Page>

Creates an about:blank page with its own owner thread.

close(): Promise<void>

Closes child pages and then the browser. Closing more than once is safe.

goto(
url: string,
options?: { timeoutMs?: number; signal?: AbortSignal },
): Promise<void>

Navigates the page. The default timeout is 30,000 milliseconds. Aborting the signal cancels the core operation and its network request.

evaluate(expression: string): Promise<unknown>

Evaluates JavaScript and returns a JSON-compatible value.

title(): Promise<string>
textContent(): Promise<string>

title() returns the current document title. textContent() returns the canonical document text output.

screenshot(options?: { fullPage?: boolean }): Promise<Buffer>

Returns a PNG Buffer for the viewport or full page.

close(): Promise<void>

Closes page resources. Closing more than once is safe.

Operations reject with BrimpError. Its code is one of:

invalid_input transport http_status navigation javascript
timeout cancelled unsupported closed screenshot internal

The native Node API does not expose locators, browser modes, raw CDP dispatch, or a request/response object. Use brimp cdp when the supported Puppeteer interface is the better fit.