Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/webviewjs/webview/llms.txt

Use this file to discover all available pages before exploring further.

This page catalogs every type exported from @webviewjs/webview that is shared across multiple parts of the API. Consult it when you need the exact shape of a payload, the numeric value of an enum member, or the precise signature of a utility type. Types that belong entirely to one feature area are documented in detail on their own page (Tray, Notification, Menu, BrowserWindow, Webview) — cross-references are provided below.

Enums

ControlFlow

Controls how the native tao event loop behaves between events. Kept for backward compatibility; normal applications use app.run() or app.whenReady() instead.
MemberValueDescription
Poll0Pump events as fast as possible without sleeping
Wait1Block until the next event arrives
WaitUntil2Block until a specific instant or the next event
Exit3Exit the event loop cleanly
ExitWithCode4Exit with a specific process exit code
import { ControlFlow } from '@webviewjs/webview';

const app = new Application({ controlFlow: ControlFlow.Wait });

CursorType

Cursor shape values passed to BrowserWindow.setCursor().
MemberValueMemberValue
Default0Crosshair1
Hand2Arrow3
Move4Text5
Wait6Help7
Progress8NotAllowed9
ContextMenu10Cell11
VerticalText12Alias13
Copy14NoDrop15
Grab16Grabbing17
ZoomIn18ZoomOut19
ResizeEast20ResizeNorth21
ResizeNorthEast22ResizeNorthWest23
ResizeSouth24ResizeSouthEast25
ResizeSouthWest26ResizeWest27
ResizeEastWest28ResizeNorthSouth29
ResizeNorthEastSouthWest30ResizeNorthWestSouthEast31
ResizeColumn32ResizeRow33
AllScroll34
import { CursorType } from '@webviewjs/webview';

win.setCursor(CursorType.Hand);

FullscreenType

Passed to BrowserWindow.setFullscreen() and BrowserWindowOptions.fullscreen.
MemberValueDescription
Exclusive0Exclusive fullscreen — takes over the entire display
Borderless1Borderless windowed fullscreen — window fills the screen with no chrome
import { FullscreenType } from '@webviewjs/webview';

win.setFullscreen(FullscreenType.Borderless);

IosValidOrientations

Passed to BrowserWindow.setValidOrientations() and BrowserWindowOptions.iosValidOrientations on iOS.
MemberValueDescription
LandscapeAndPortrait0Allow all orientations
Landscape1Landscape only
Portrait2Portrait only

ProgressBarState

Passed inside JsProgressBar to BrowserWindow.setProgressBar().
MemberValueDescription
None0No progress indicator
Normal1Standard progress bar
Indeterminate2Spinning/pulsing indicator
Paused3Paused state (yellow on Windows)
Error4Error state (red on Windows)
import { ProgressBarState } from '@webviewjs/webview';

win.setProgressBar({ state: ProgressBarState.Normal, progress: 42 });

Theme

Passed to BrowserWindowOptions and WebviewOptions.theme.
MemberValueDescription
Light0Force light theme
Dark1Force dark theme
System2Follow the OS preference

WebviewApplicationEvent

Discriminant values for ApplicationEvent.event. In normal code you key on the string event name passed to app.on(), not on this numeric enum.
MemberValueapp.on() name
WindowCloseRequested0"window-close-requested"
ApplicationCloseRequested1"application-close-requested"
CustomMenuClick2"custom-menu-click"
Ready3"ready"

WebviewEventType

Numeric discriminant carried in WebviewEventPayload.event. Normal code keys on the string name via webview.on().
MemberValuewebview.on() name
PageLoadStarted0"page-load-started"
PageLoadFinished1"page-load-finished"
TitleChanged2"title-changed"
DownloadStarted3"download-started"
DownloadCompleted4"download-completed"
NavigationStarted5"navigation"
NewWindowRequested6"new-window"

WindowEventType

Numeric discriminant carried in WindowEventPayload.event. Normal code keys on the string name via win.on().
MemberValuewin.on() nameTyped payloadKey payload fields
Moved0"move"WindowMoveEventx, y (physical px, outer position)
Resized1"resize"WindowResizeEventwidth, height (physical px, inner size)
CloseRequested2"close"WindowBaseEvent
Focused3"focus"WindowBaseEvent
Blurred4"blur"WindowBaseEvent
MouseEnter5"mouse-enter"WindowMouseEventx, y
MouseLeave6"mouse-leave"WindowBaseEvent
MouseMove7"mouse-move"WindowMouseEventx, y
MouseDown8"mouse-down"WindowMouseEventx, y, button
MouseUp9"mouse-up"WindowMouseEventx, y, button
Scroll10"scroll"WindowScrollEventdeltaX, deltaY
KeyDown11"key-down"WindowKeyEventkey, code, modifiers, isRepeat
KeyUp12"key-up"WindowKeyEventkey, code, modifiers
FileDrop13"file-drop"WindowFileEventfiles
FileHover14"file-hover"WindowFileEventfiles
FileHoverCancelled15"file-hover-cancelled"WindowBaseEvent
ScaleFactorChanged16"scale-factor-changed"WindowScaleEventscaleFactor
ThemeChanged17"theme-changed"WindowThemeEventtext ("light" | "dark")
Ime18"ime"WindowImeEventtext, phase
Touch19"touch"WindowTouchEventx, y, touchId, phase

Interfaces

AndroidContentRect

Inset rectangle reported by BrowserWindow.androidContentRect() on Android.
interface AndroidContentRect {
  left:   number;
  top:    number;
  right:  number;
  bottom: number;
}

ApplicationEvent

Payload delivered to app.on() listeners.
event
WebviewApplicationEvent
Numeric discriminant identifying the event type.
customMenuEvent
CustomMenuEvent | undefined
Present only for CustomMenuClick events.

ApplicationOptions

Passed to new Application(options?).
controlFlow
ControlFlow
Event-loop scheduling strategy. Defaults to the Rust tao default.
waitTime
number
Maximum milliseconds to wait between event-loop ticks when using ControlFlow.WaitUntil.
exitCode
number
Process exit code used when ControlFlow.ExitWithCode terminates the loop.

ApplicationRunOptions

Passed to app.run(options?).
interval
number
Milliseconds between event-loop pumps. Defaults to 16 (≈60 FPS).
ref
boolean
Whether the pump timer should keep the Node.js event loop alive. Defaults to true.

ApplicationWhenReadyOptions

Passed to app.whenReady(options?). Two overloads exist:
// autoRun: true (default) — app.run() is called automatically after the promise resolves
{ autoRun?: true;  interval?: number; ref?: boolean }

// autoRun: false — you are responsible for calling app.run() yourself
{ autoRun: false }

CustomMenuEvent

Carried inside ApplicationEvent for custom-menu-click events.
id
string
The id set on the MenuItemOptions that was activated.
windowId
number
Numeric identifier of the window whose menu bar contained the item.

CustomProtocolRequest

Legacy plain-object shape delivered to low-level protocol handlers. The public BrowserWindow.registerProtocol() callback receives a standard Fetch API Request instead.
url
string
Full URL, e.g. "app://localhost/index.html".
method
string
HTTP method string, e.g. "GET", "POST".
headers
HeaderData[]
Request headers as key/value pairs.
body
Buffer | undefined
Request body bytes. Present for POST / PUT requests.

CustomProtocolResponse

Returned by protocol handlers. registerProtocol() also accepts a standard Fetch API Response.
body
Buffer
Response body bytes. Required.
mimeType
string | undefined
MIME type, e.g. "text/html". Defaults to "application/octet-stream".
statusCode
number | undefined
HTTP status code. Defaults to 200.
headers
HeaderData[] | undefined
Additional response headers.

Dimensions

A width/height pair used throughout the API.
interface Dimensions { width: number; height: number; }

ExposeCallData

Delivered to the internal handler when the page calls a function exposed via webview.expose().
ns
string
The namespace name passed to expose().
method
string
The function name the page called.
id
number
Unique call ID used to route the response back.
argsJson
string
JSON-serialized array of arguments the page passed.

FileDialogOptions

Passed to BrowserWindow.openFileDialog().
multiple
boolean
Allow selecting multiple files. Defaults to false.
title
string
Dialog window title.
defaultPath
string
Initial directory or file path.
filters
FileFilter[]
File type filters shown in the dialog.

HeaderData

A single HTTP header key/value pair used in protocol requests and responses.
interface HeaderData { key: string; value?: string; }

IpcMessage

Received by the webview.onIpcMessage() callback when page JavaScript calls window.ipc.postMessage().
body
Buffer
Raw message body bytes.
method
string
HTTP-style method string.
headers
HeaderData[]
IPC message headers.
uri
string
Destination URI.

JsProgressBar

Passed to BrowserWindow.setProgressBar().
state
ProgressBarState | undefined
Visual state of the progress bar.
progress
number | undefined
Progress value (0–100).

Monitor

Describes a physical display, returned by BrowserWindow.getAvailableMonitors() and related methods.
name
string | undefined
Platform display name.
scaleFactor
number
DPI scale factor (e.g. 2 for HiDPI).
size
Dimensions
Display resolution in physical pixels.
position
Position
Top-left corner of the monitor in the virtual screen space.
videoModes
VideoMode[]
Available video modes for this display.

VideoMode

One entry in Monitor.videoModes.
size
Dimensions
Resolution in physical pixels.
bitDepth
number
Color depth in bits per pixel.
refreshRate
number
Refresh rate in Hz.

NativeNotificationOptions

Low-level options consumed by the NativeNotification NAPI class. Normal application code uses the higher-level Notification class instead.
title
string
Notification title.
body
string | undefined
Body text.
icon
string | undefined
Icon path or platform name.
imagePath
string | undefined
Local file path for the inline image.
imageData
Buffer | undefined
Encoded image bytes for the inline image.
requireInteraction
boolean | undefined
Persist until interaction.
persistent
boolean
Keep process alive until interaction or closure.
actions
NativeNotificationAction[]
Action buttons.

NativeNotificationAction

interface NativeNotificationAction { action: string; title: string; icon?: string; }

Position

An x/y coordinate pair.
interface Position { x: number; y: number; }

WebContextOptions

Passed to app.createWebContext().
dataDirectory
string
Custom path for WebView data storage. Useful on Windows when the application is installed in Program Files.
allowsAutomation
boolean
Enable WebDriver automation for testing. Currently only enforced on Linux. At most one context may have automation enabled at a time.

WebviewBounds

Logical-pixel rectangle used by Webview.setBounds() / getBounds().
interface WebviewBounds { x: number; y: number; width: number; height: number; }

WebviewCookie

Represents a browser cookie, used with Webview.getCookies(), setCookie(), and deleteCookie().
name
string
Cookie name.
value
string
Cookie value.
domain
string | undefined
Scope domain.
path
string | undefined
Scope path.
httpOnly
boolean | undefined
Whether the cookie is HTTP-only.
secure
boolean | undefined
Whether the cookie requires HTTPS.
sameSite
"strict" | "lax" | "none" | undefined
SameSite policy.

WebviewEventPayload

Delivered to the internal webview event callback. Normal code uses webview.on() string events.
event
WebviewEventType
Numeric event discriminant.
url
string | undefined
URL for navigation, page-load, and download events.
title
string | undefined
Document title for TitleChanged events.
success
boolean | undefined
Download success flag for DownloadCompleted events.

Webview event interfaces

Typed payloads delivered to webview.on() listeners, keyed by the WebviewEventMap.
interface WebviewPageLoadEvent      { event: number; url?: string; }
interface WebviewTitleChangedEvent  { event: number; title?: string; }
interface WebviewDownloadEvent      { event: number; url?: string; success?: boolean; }
interface WebviewDownloadStartedEvent extends WebviewDownloadEvent {}
interface WebviewNavigationEvent    { event: number; url?: string; }
interface WebviewNewWindowEvent     { event: number; url?: string; }
WebviewEventMap — maps webview.on() event names to their typed payloads:
Event namePayload type
"page-load-started"WebviewPageLoadEvent
"page-load-finished"WebviewPageLoadEvent
"title-changed"WebviewTitleChangedEvent
"download-started"WebviewDownloadStartedEvent
"download-completed"WebviewDownloadEvent
"navigation"WebviewNavigationEvent
"new-window"WebviewNewWindowEvent

Window event interfaces

Typed payloads delivered to win.on() listeners, keyed by BrowserWindowEventMap. All interfaces carry an event: number discriminant matching the WindowEventType value.
interface WindowBaseEvent   { event: number; }
interface WindowMoveEvent   { event: number; x: number; y: number; }
interface WindowResizeEvent { event: number; width: number; height: number; }

interface WindowMouseEvent  {
  event: number;
  x: number;
  y: number;
  button?: number;    // 0=left, 1=middle, 2=right
  modifiers?: number; // bitmask: 1=Shift, 2=Ctrl, 4=Alt, 8=Meta
}

interface WindowScrollEvent { event: number; deltaX: number; deltaY: number; }

interface WindowKeyEvent {
  event: number;
  key?: string;       // DOM KeyboardEvent.key, e.g. "a", "Enter", "ArrowLeft"
  code?: string;      // DOM KeyboardEvent.code, e.g. "KeyA", "ArrowLeft"
  modifiers?: number;
  isRepeat?: boolean;
}

interface WindowFileEvent   { event: number; files?: string[]; }
interface WindowScaleEvent  { event: number; scaleFactor: number; }
interface WindowThemeEvent  { event: number; text: 'light' | 'dark'; }

interface WindowImeEvent {
  event: number;
  text?: string;
  phase: 'enabled' | 'preedit' | 'commit' | 'disabled';
}

interface WindowTouchEvent {
  event: number;
  x: number;
  y: number;
  touchId: number;
  phase: 'started' | 'moved' | 'ended' | 'cancelled';
}

WindowEventPayload

Delivered to the internal window event callback. Normal code uses win.on() string events.
event
WindowEventType
Numeric event discriminant.
x
number | undefined
Physical x position (cursor or outer window).
y
number | undefined
Physical y position (cursor or outer window).
width
number | undefined
Physical width (resize events).
height
number | undefined
Physical height (resize events).
button
number | undefined
Mouse button index: 0=left, 1=middle, 2=right.
deltaX
number | undefined
Horizontal scroll delta in pixels.
deltaY
number | undefined
Vertical scroll delta in pixels.
key
string | undefined
DOM KeyboardEvent.key value, e.g. "a", "Enter", "ArrowLeft".
code
string | undefined
DOM KeyboardEvent.code value, e.g. "KeyA", "ArrowLeft".
modifiers
number | undefined
Modifier bitmask: 1=Shift, 2=Ctrl, 4=Alt, 8=Meta/Super/Command.
isRepeat
boolean | undefined
Whether the key event is a repeat from holding the key.
files
string[] | undefined
File paths for FileDrop / FileHover events.
scaleFactor
number | undefined
DPI scale factor for ScaleFactorChanged events.
text
string | undefined
IME preedit/committed text, or "light" / "dark" for ThemeChanged events.
touchId
number | undefined
Touch point identifier for Touch events.
phase
string | undefined
Phase string: "started" / "moved" / "ended" / "cancelled" for Touch; "enabled" / "preedit" / "commit" / "disabled" for IME.

Helper Types

JsonValue

Represents any JSON-serializable value. Used as the constraint for static properties exposed via webview.expose().
type JsonValue =
  | null
  | boolean
  | number
  | string
  | JsonValue[]
  | { [key: string]: JsonValue };

ExposedTarget

The shape of the object passed to webview.expose(name, target). Values may be JsonValue (serialized as static properties) or functions (proxied as async stubs in the page).
type ExposedTarget = Record<
  string,
  JsonValue | ((...args: any[]) => unknown | Promise<unknown>)
>;

EventListener<TPayload>

Typed event listener callback used throughout the TypedEventEmitter interface.
type EventListener<TPayload> = (payload: TPayload) => void;

TypedEventEmitter<TEventMap>

The shared EventEmitter interface implemented by Application, BrowserWindow, Webview, TrayIcon, Notification, and WebContext. TEventMap maps event name strings to their payload types.
interface TypedEventEmitter<TEventMap extends object> {
  on(event: keyof TEventMap, listener: EventListener<...>): this;
  once(event: keyof TEventMap, listener: EventListener<...>): this;
  off(event: keyof TEventMap, listener: EventListener<...>): this;
  addListener(event: keyof TEventMap, listener: EventListener<...>): this;
  removeListener(event: keyof TEventMap, listener: EventListener<...>): this;
  removeAllListeners(event?: string | symbol): this;
  listenerCount(event: keyof TEventMap, listener?: EventListener<...>): number;
  listeners(event: keyof TEventMap): Array<EventListener<...>>;
  rawListeners(event: keyof TEventMap): Array<EventListener<...>>;
  emit(event: keyof TEventMap, payload: ...): boolean;
  eventNames(): Array<keyof TEventMap | string | symbol>;
}

SerializationError

Extends Error. Thrown (or used to reject returned Promises) by webview.expose() when an argument, return value, or static property cannot be serialized to JSON.
class SerializationError extends Error {
  name: 'SerializationError';
}

BrowserWindowEventMap

Maps win.on() event names to their typed payload interfaces. All payloads include an event: number discriminant.
interface BrowserWindowEventMap {
  move:                  WindowMoveEvent;
  resize:                WindowResizeEvent;
  close:                 WindowBaseEvent;
  focus:                 WindowBaseEvent;
  blur:                  WindowBaseEvent;
  'mouse-enter':         WindowMouseEvent;
  'mouse-leave':         WindowBaseEvent;
  'mouse-move':          WindowMouseEvent;
  'mouse-down':          WindowMouseEvent;
  'mouse-up':            WindowMouseEvent;
  scroll:                WindowScrollEvent;
  'key-down':            WindowKeyEvent;
  'key-up':              WindowKeyEvent;
  'file-drop':           WindowFileEvent;
  'file-hover':          WindowFileEvent;
  'file-hover-cancelled': WindowBaseEvent;
  'scale-factor-changed': WindowScaleEvent;
  'theme-changed':        WindowThemeEvent;
  ime:                   WindowImeEvent;
  touch:                 WindowTouchEvent;
}

ApplicationEventMap

Maps app.on() event names to their typed payload.
interface ApplicationEventMap {
  'window-close-requested':      ApplicationEvent;
  'application-close-requested': ApplicationEvent;
  'custom-menu-click':           ApplicationEvent;
  'ready':                       ApplicationEvent;
}

TrayEventMap

Maps tray.on() event names to their typed payload. See the Tray Icon API page for full details.
interface TrayEventMap {
  click:        TrayEventPayload;
  'double-click': TrayEventPayload;
  enter:        TrayEventPayload;
  move:         TrayEventPayload;
  leave:        TrayEventPayload;
}

Notification types

TypeDefinition
NotificationPermission'granted'
NotificationDirection'auto' | 'ltr' | 'rtl'
NotificationEventName'click' | 'close' | 'error' | 'show'
See the Notification API page for the full Notification class, NotificationOptions, NotificationAction, and NotificationEvent documentation.

Tray types

TrayIconOptions, TrayIconImage, TrayRect, and TrayEventPayload are documented in full on the Tray Icon API page.
MenuOptions and MenuItemOptions are documented in full on the Menu API page.

Standalone Exports

getWebviewVersion()

function getWebviewVersion(): string
Returns the version string of the underlying wry/WebView2/WKWebView engine at runtime. Useful for diagnostics and feature detection.
import { getWebviewVersion } from '@webviewjs/webview';

console.log(getWebviewVersion()); // e.g. "0.44.0"

VERSION

const VERSION: string
The current version of the @webviewjs/webview package, inlined at build time.
import { VERSION } from '@webviewjs/webview';

console.log(VERSION); // e.g. "0.4.2"

Build docs developers (and LLMs) love