{"id":13839788,"url":"https://github.com/webview/webview_csharp","last_synced_at":"2025-04-04T18:09:36.961Z","repository":{"id":42075959,"uuid":"258739524","full_name":"webview/webview_csharp","owner":"webview","description":"C# bindings for webview/webview - Batteries included","archived":false,"fork":false,"pushed_at":"2024-07-13T03:33:01.000Z","size":3869,"stargazers_count":182,"open_issues_count":7,"forks_count":30,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-28T17:11:11.967Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/webview.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-25T09:54:22.000Z","updated_at":"2025-03-22T22:56:00.000Z","dependencies_parsed_at":"2024-06-20T10:22:17.076Z","dependency_job_id":"3b522b9c-c453-4910-9528-e45a70d0639a","html_url":"https://github.com/webview/webview_csharp","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webview%2Fwebview_csharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webview%2Fwebview_csharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webview%2Fwebview_csharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webview%2Fwebview_csharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webview","download_url":"https://codeload.github.com/webview/webview_csharp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247226215,"owners_count":20904465,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T17:00:35.430Z","updated_at":"2025-04-04T18:09:36.945Z","avatar_url":"https://github.com/webview.png","language":"C","readme":"[![ReleaseBuild](https://github.com/webview/sharpWebview/workflows/ReleaseBuild/badge.svg)](https://github.com/webview/sharpWebview/actions?query=workflow%3AReleaseBuild)\n[![WebviewNative](https://github.com/webview/sharpWebview/workflows/WebviewNative/badge.svg)](https://github.com/webview/sharpWebview/actions?query=workflow%3AWebviewNative)\n[![Nuget](https://img.shields.io/nuget/v/SharpWebview?color=green)](https://www.nuget.org/packages/SharpWebview/)\n[![Webview Org Chat](https://img.shields.io/badge/chat-on%20discord-7289da.svg)](https://discord.gg/grzBQBP)\n\n# sharpWebview\n\nThis repository contains battery included C# bindings for [webview](https://github.com/webview/webview). **It only supports x64 systems.**\n\n# Webview\n\n[webview](https://github.com/webview/webview) is a small C/C++ header only library for a cross platform access of a webview control.\nIt uses Edge Chromium, with fallback to the 'old' Edge, on Windows, GTK Webkit on Linux and Cocoa Webkit on macOS.\n*sharpWebview* ships precompiled libraries for each system, ready to be used in your next C# project. This repository contains a cmake file to compile webview via *Github Actions* [![WebviewNative](https://github.com/webview/sharpWebview/workflows/WebviewNative/badge.svg)](https://github.com/webview/sharpWebview/actions?query=workflow%3AWebviewNative).\n\nYou are always able to see which webview version *sharpWebview* uses by looking into the [CMakeLists.txt](https://github.com/webview/sharpWebview/blob/master/CMakeLists.txt) (GIT_TAG option in the *FetchContent_Declare* command). You can find all compiled libraries and used patches in the [libs](https://github.com/webview/sharpWebview/tree/master/libs) folder of this repository.\n\n# Get started\n\n## Linux Prerequisites\n\nPlease install the developer packages of webkit2gtk and libgtk on your machine. \n\nWith a distribution using apt run:  \n```\nsudo apt install -y libwebkit2gtk-4.0-dev libgtk-3-dev\n```\n\nor DNF\n```\nsudo dnf install webkit2gtk4,0-devel.x86_64 gtk3-devel.x84_64\n```\n\n## A basic example\n\nCreate a new .net core console application and add the **SharpWebview** nuget. Use the dotnet command line or the package management in Visual Studio, if you use it.\n\n```\ndotnet add package SharpWebview\n```\n\nAlways add the *[STAThread]* attribute to the main method. This is necessary to work on windows at least.\n\n```csharp\n[STAThread]\nstatic void Main(string[] args)\n```\n\nTo create a webview use a *using* block. This way you make sure that the native webview gets disposed correctly!\n\n```csharp\nusing SharpWebview;\n\n[...]\n\nusing(var webview = new Webview())\n{\n}\n```\n\nTo open a basic webview which is pointing to a wikipedia article use the following code:\n\n```csharp\nusing(var webview = new Webview())\n{\n    webview\n        .SetTitle(\"The Hitchhicker\")             \n        .SetSize(1024, 768, WebviewHint.None)\n        .SetSize(800, 600, WebviewHint.Min)\n        .Navigate(new UrlContent(\"https://en.wikipedia.org/wiki/The_Hitchhiker%27s_Guide_to_the_Galaxy_(novel)\"))\n        .Run();\n}\n```\n\nThe [examples](https://github.com/webview/sharpWebview/tree/master/examples) folder contains two basic projects. The [*Minimal*](https://github.com/webview/sharpWebview/tree/master/examples/Minimal) projects shows you a basic example on how to create a cross platform webview and how to open a URL in it.\nPlease have a look into the documented [*Program.cs*](https://github.com/webview/sharpWebview/blob/master/examples/Minimal/Program.cs). You are also able to use the *HtmlContent* to provide some HTML which the webview will render.\n\n## Run a webserver to serve a javascript application\n\nBesides the *UrlContent* and *HtmlContent*, *sharpWebview* also provides a *HostedContent*. This content type creates a webserver to which the webview will automatically navigate.\n\nTo use this content it is necessary to create a *app* folder in your project. Every file you put into this folder will be served by the *HostedContent*. The [*DesktopApp*](https://github.com/webview/sharpWebview/tree/master/examples/DesktopApp) project is an example of the usage of this content type.\nDon't forget to set the files in the *app* folder to *copy always* (see project file for an example).\n\n### HostedContent on Windows systems\n\nThe Edge webview uses a UWP application context on windows. UWP applications disallow loopbacks. For development purpose it is necessary to run the following command in an administrative command prompt:\n\n```\nCheckNetIsolation.exe LoopbackExempt -a -n=\"Microsoft.Win32WebViewHost_cw5n1h2txyewy\"\n```\n\nThis adds the Edge Webview Host to the exception list of this limitation. Your best bet for application distribution is to create an installer which executes this command on installation.\n\n# Application Distribution\n## Windows\n \nThe [*DesktopApp*](https://github.com/webview/sharpWebview/tree/master/examples/DesktopApp) example contains a simple script to create a MSI installer. You are able to take the *wix.bat* and *DesktopApp.wix* files as a starting point for your application. To use the *wix.bat* you need to install the WIX Toolset.\n\nI highly recommend to use [scoop](https://scoop.sh/) to install it. Scoop is a command line installer for easy installation of many different applications. Just run \n\n```\nscoop install wixtoolset\n```\n\nto install WIX. After this you should be able to execute the *wix.bat* to create a basic installer for the example [*DesktopApp*](https://github.com/webview/sharpWebview/tree/master/examples/DesktopApp).\n","funding_links":[],"categories":["C# #","C# (212)","C"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebview%2Fwebview_csharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebview%2Fwebview_csharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebview%2Fwebview_csharp/lists"}