# WebView2 Package

The **WebView2Package** wraps the Microsoft Edge WebView2 runtime and exposes it as an ordinary twinBASIC control. Drop a [**WebView2**](/tB/Packages/WebView2/WebView2/index.md) onto a form and the running Edge engine renders web content inside it --- navigate to URLs, run JavaScript, intercept HTTP requests, post messages between BASIC and JavaScript, and print pages to PDF.

![A window titled WebView2 Demo, with a WebView2 control filling most of the form. The control shows a web page that the form passed to NavigateToString: a blue heading, Hello from a WebView2, a paragraph, three bullet points, and a pale blue box holding a line that the form's code set by calling a JavaScript function of the page with JsRun.](/Reference/Built-In/WebView2/WebView2/Images/WebView2_Page.png){:width="601" height="381"}

The package is a built-in package shipped with twinBASIC. See the [WebView2 tutorials](/Tutorials/WebView2/index.md) for how to reference it in a project, and worked samples.

Beyond the control itself, the package exposes a small set of wrapper objects that appear inside the control's event arguments --- the request / response pair on **WebResourceRequested**, the request-header collection on **NavigationStarting**, the environment-options object configured before **Create** --- together with the `wv2…` enumerations used to spell out option values.

## Classes

- [WebView2](/tB/Packages/WebView2/WebView2/index.md) -- the control: navigation, scripting, settings, deferral-aware events, and PDF / suspend / download / task-manager features controlled by the underlying Edge runtime
- [WebView2EnvironmentOptions](/tB/Packages/WebView2/WebView2/EnvironmentOptions.md) -- pre-creation configuration for the WebView2 environment (user-data folder, executable folder, locale, tracking-prevention, …); reached via the control's **EnvironmentOptions** property
- [WebView2Header](/tB/Packages/WebView2/WebView2Header.md) -- one HTTP header (Name / Value); the element type yielded by header iteration
- [WebView2HeadersCollection](/tB/Packages/WebView2/WebView2HeadersCollection.md) -- enumerator returned by **GetHeaders** and used by `For Each` over request / response headers; also describes its four derived classes
- [WebView2Request](/tB/Packages/WebView2/WebView2Request.md) -- the request side of a **WebResourceRequested** event -- **Method**, **Uri**, **Headers**, and the request body as bytes or UTF-8 text
- [WebView2RequestHeaders](/tB/Packages/WebView2/WebView2RequestHeaders.md) -- mutable request-header collection passed to **NavigationStarting** and reached via **WebView2Request.Headers**
- [WebView2Response](/tB/Packages/WebView2/WebView2Response.md) -- the response side of a **WebResourceRequested** event -- **StatusCode**, **ReasonPhrase**, **Headers**, and the body as bytes or UTF-8 text
- [WebView2ResponseHeaders](/tB/Packages/WebView2/WebView2ResponseHeaders.md) -- mutable response-header collection reached via **WebView2Response.Headers**

## Enumerations

- [wv2DefaultDownloadCornerAlign](/tB/Packages/WebView2/Enumerations/wv2DefaultDownloadCornerAlign.md) -- anchors the built-in download-progress dialog to one corner of the control
- [wv2ErrorStatus](/tB/Packages/WebView2/Enumerations/wv2ErrorStatus.md) -- reason a navigation failed; reported by **NavigationComplete**
- [wv2HostResourceAccessKind](/tB/Packages/WebView2/Enumerations/wv2HostResourceAccessKind.md) -- access policy for a virtual hostname registered with **SetVirtualHostNameToFolderMapping**
- [wv2KeyEventKind](/tB/Packages/WebView2/Enumerations/wv2KeyEventKind.md) -- the kind of accelerator-key keyboard message in **AcceleratorKeyPressed**
- [wv2PermissionKind](/tB/Packages/WebView2/Enumerations/wv2PermissionKind.md) -- device or browser capability a page is asking permission to use; passed by **PermissionRequested**
- [wv2PermissionState](/tB/Packages/WebView2/Enumerations/wv2PermissionState.md) -- the host's decision (grant / deny / default) on a **PermissionRequested** event
- [wv2PrintOrientation](/tB/Packages/WebView2/Enumerations/wv2PrintOrientation.md) -- page orientation passed to **PrintToPdf**
- [wv2ProcessFailedKind](/tB/Packages/WebView2/Enumerations/wv2ProcessFailedKind.md) -- which of the external WebView2 processes failed; reported by **ProcessFailed**
- [wv2ScriptDialogKind](/tB/Packages/WebView2/Enumerations/wv2ScriptDialogKind.md) -- which JavaScript-dialog primitive is opening; passed by **ScriptDialogOpening**
- [wv2WebResourceContext](/tB/Packages/WebView2/Enumerations/wv2WebResourceContext.md) -- kind of HTTP request a filter registered with **AddWebResourceRequestedFilter** should match

## Types

- [COREWEBVIEW2_PHYSICAL_KEY_STATUS](/tB/Packages/WebView2/Types/COREWEBVIEW2_PHYSICAL_KEY_STATUS.md) -- decoded `WM_KEYDOWN` / `WM_KEYUP` `lParam` bit-fields; delivered via the **AcceleratorKeyPressed** event

## Tutorials

- [Getting started](/Tutorials/WebView2/Getting-Started.md) -- adding the package references and dropping a control onto a form
- [Customize the UserDataFolder](/Tutorials/WebView2/Customize-UserDataFolder.md) -- relocating the runtime's working folder for hosted scenarios (Office add-ins, kiosk installs)
- [Re-entrancy](/Tutorials/WebView2/Re-entrancy.md) -- what the control's deferred-event machinery handles automatically, and the **AddObject** synchronous-vs-deferred trade-off
- [Building a browser shell](/Tutorials/WebView2/Building-A-Browser-Shell.md) -- address bar, back / forward / reload, zoom, PDF export
- [Hosting local web assets](/Tutorials/WebView2/Hosting-Local-Web-Assets.md) -- serve HTML / JS / CSS from a project resource folder, without an HTTP server
- [JavaScript interop](/Tutorials/WebView2/JavaScript-Interop.md) -- the three bridges between BASIC and the page: host objects, messages, and scripted calls
- [Driving Monaco from twinBASIC](/Tutorials/WebView2/Driving-Monaco.md) -- case study combining everything above
