Crate webview2[][src]

Expand description

Rust bindings for WebView2:

The Microsoft Edge WebView2 control enables you to embed web technologies (HTML, CSS, and JavaScript) in your native applications. The WebView2 control uses Microsoft Edge (Chromium) as the rendering engine to display the web content in native applications. With WebView2, you may embed web code in different parts of your native application, or build the entire native application within a single WebView. For information on how to start building a WebView2 application, see Get Started.


The webview2 crate contains high-level, idiomatic wrappers for the raw COM APIs, which can be found in the webview2-sys crate.

The API mapping should be quite straightforward.

The CreateCoreWebView2EnvironmentWithDetails function does not have a direct equivalent. It is replaced with a nicer EnvironmentBuilder API. The GetAvailableCoreWebView2BrowserVersionString and CompareBrowserVersions functions are also exposed through the builder.


The Edge browser from beta, dev or canary channels (>= 86.0.622.0) or the Evergreen WebView2 Runtime need to be installed for this to actually work. Or the build method will return an error.


A binary library WebView2Loader from the WebView2 SDK need to be used, either the DLL WebView2Loader.dll or the static library WebView2LoaderStatic.lib. This brings some complexities:

  • When using the gnu toolchain, the static library does not seem to work so the WebView2Loader.dll DLL is used. You need to make sure that the DLL can be loaded at runtime, e.g. by putting it alongside the built exe files.

  • When using the msvc toolchain, the static library is used. Make sure you have the v142 toolset (or visual studio 2019), because the static library seem to be built with visual studio 2019 and could not be correctly linked by earlier versions of the visual studio. See C++ binary compatibility between Visual Studio 2015, 2017, and 2019.


See the examples directory, especially the heavily commented win32 example.


Returns a pointer that implements the COM callback interface with the specified closure. Inspired by C++ Microsoft::WRT::Callback.


Wrapper for ICoreWebView2AcceleratorKeyPressedEventArgs.

Wrapper for ICoreWebView2ClientCertificate.

Wrapper for ICoreWebView2ClientCertificateCollection.

Wrapper for ICoreWebView2ClientCertificateRequestedEventArgs.

Wrapper for ICoreWebView2CompositionController.

Wrapper for ICoreWebView2CompositionController2.

Wrapper for ICoreWebView2CompositionControllerInterop.

Wrapper for ICoreWebView2ContentLoadingEventArgs.

Wrapper for ICoreWebView2Controller.

Wrapper for ICoreWebView2Controller2.

Wrapper for ICoreWebView2Controller3.

Wrapper for ICoreWebView2Cookie.

Wrapper for ICoreWebView2CookieList.

Wrapper for ICoreWebView2CookieManager.

Wrapper for ICoreWebView2DOMContentLoadedEventArgs.

Wrapper for ICoreWebView2Deferral.

Wrapper for ICoreWebView2DevToolsProtocolEventReceivedEventArgs.

Wrapper for ICoreWebView2DevToolsProtocolEventReceiver.

Wrapper for ICoreWebView2DownloadOperation.

Wrapper for ICoreWebView2DownloadStartingEventArgs.

Wrapper for ICoreWebView2Environment.

Wrapper for ICoreWebView2Environment2.

Wrapper for ICoreWebView2Environment3.

Wrapper for ICoreWebView2Environment4.

A builder for calling the CreateCoreWebView2EnvironmentWithOptions function.

Wrapper for ICoreWebView2EnvironmentInterop.

Wrapper for ICoreWebView2EnvironmentOptions.

WebView2 Error.

Represents a reference to a delegate that receives change notifications.

Wrapper for ICoreWebView2Frame.

Wrapper for ICoreWebView2FrameCreatedEventArgs.

Wrapper for ICoreWebView2FrameInfo.

Wrapper for ICoreWebView2FrameInfoCollection.

Wrapper for ICoreWebView2FrameInfoCollectionIterator.

Wrapper for ICoreWebView2HttpHeadersCollectionIterator.

Wrapper for ICoreWebView2HttpRequestHeaders.

Wrapper for ICoreWebView2HttpResponseHeaders.

Wrapper for ICoreWebView2Interop.

Wrapper for ICoreWebView2MoveFocusRequestedEventArgs.

Wrapper for ICoreWebView2NavigationCompletedEventArgs.

Wrapper for ICoreWebView2NavigationStartingEventArgs.

Wrapper for ICoreWebView2NewWindowRequestedEventArgs.

Wrapper for ICoreWebView2PermissionRequestedEventArgs.

Contains the information packed into the LPARAM sent to a Win32 key event. For more information about WM_KEYDOWN, navigate to [WM_KEYDOWN message][WindowsWin32InputdevWmKeydown].

Wrapper for ICoreWebView2PointerInfo.

Wrapper for ICoreWebView2ProcessFailedEventArgs.

Wrapper for ICoreWebView2ProcessFailedEventArgs2.

Wrapper for ICoreWebView2ScriptDialogOpeningEventArgs.

Wrapper for ICoreWebView2Settings.

Wrapper for ICoreWebView2Settings2.

Wrapper for ICoreWebView2Settings3.

Wrapper for ICoreWebView2Settings4.

Wrapper for ICoreWebView2Settings5.

Wrapper for ICoreWebView2SourceChangedEventArgs.

Wrapper for IStream.

Wrapper for ICoreWebView2StringCollection.

Wrapper for ICoreWebView2WebMessageReceivedEventArgs.

Wrapper for ICoreWebView2WebResourceRequest.

Wrapper for ICoreWebView2WebResourceRequestedEventArgs.

Wrapper for ICoreWebView2WebResourceResponse.

Wrapper for ICoreWebView2WebResourceResponseReceivedEventArgs.

Wrapper for ICoreWebView2WebResourceResponseView.

Wrapper for ICoreWebView2.

Wrapper for ICoreWebView2_2.

Wrapper for ICoreWebView2_3.

Wrapper for ICoreWebView2_4.

Wrapper for ICoreWebView2_5.

Wrapper for ICoreWebView2WindowFeatures.


Specifies the image format for the ICoreWebView2::CapturePreview method.

Specifies the key event type that triggered an AcceleratorKeyPressed event.

Specifies the reason for moving focus.

Indicates the type of a permission request.

Specifies the response to a permission request.

Specifies the process failure type used in the ICoreWebView2ProcessFailedEventHandler interface. The values in this enum make reference to the process kinds in the Chromium architecture. For more information about what these processes are and what they do, see Browser Architecture - Inside look at modern web browser.

Specifies the JavaScript dialog type used in the ICoreWebView2ScriptDialogOpeningEventHandler interface.

Indicates the error status values for web navigations.

Specifies the web resource request contexts.


Check a HRESULT, if it is SUCCEEDED, return Ok(()). Otherwide return an error containing the HRESULT.

Type Definitions