{"id":14155955,"url":"https://github.com/tr1ckydev/webview-bun","last_synced_at":"2025-04-08T08:18:17.384Z","repository":{"id":181664737,"uuid":"665969286","full_name":"tr1ckydev/webview-bun","owner":"tr1ckydev","description":"Bun bindings for webview, a tiny library for creating web-based desktop GUIs.","archived":false,"fork":false,"pushed_at":"2024-10-30T12:21:53.000Z","size":860,"stargazers_count":305,"open_issues_count":8,"forks_count":17,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-04-01T07:40:34.098Z","etag":null,"topics":["bun","ffi","webview"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/webview-bun","language":"TypeScript","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/tr1ckydev.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2023-07-13T12:05:47.000Z","updated_at":"2025-03-29T10:52:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"396ca953-333a-400f-9b13-e0bf8a8a087f","html_url":"https://github.com/tr1ckydev/webview-bun","commit_stats":{"total_commits":19,"total_committers":4,"mean_commits":4.75,"dds":0.4736842105263158,"last_synced_commit":"b885c62d433887cbf0553839a1ff2c06bf0aeefe"},"previous_names":["tr1ckydev/webview-bun"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tr1ckydev%2Fwebview-bun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tr1ckydev%2Fwebview-bun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tr1ckydev%2Fwebview-bun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tr1ckydev%2Fwebview-bun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tr1ckydev","download_url":"https://codeload.github.com/tr1ckydev/webview-bun/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247801176,"owners_count":20998339,"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":["bun","ffi","webview"],"created_at":"2024-08-17T08:05:07.001Z","updated_at":"2025-04-08T08:18:17.345Z","avatar_url":"https://github.com/tr1ckydev.png","language":"TypeScript","funding_links":[],"categories":["others","TypeScript"],"sub_categories":[],"readme":"# webview-bun\n\n[bun](https://bun.sh/) bindings for [webview](https://github.com/webview/webview/)\n\nWebview is a tiny cross-platform library to make **web-based GUIs for desktop applications**.\n\n![](banner.png)\n\n## Installation\n\n\u003cdetails\u003e\n  \u003csummary\u003eClick here for instructions on 🐧 Linux\u003c/summary\u003e\n  The compiled linux library in this package requires GTK 4 and WebkitGTK 6.\n\n\u003e To use a different version, see Development section below.\n\n- Debian-based systems: `apt install libgtk-4-1 libwebkitgtk-6.0-4`\n- Arch-based systems: `pacman -S gtk4 webkitgtk-6.0` \n- Fedora-based systems: `dnf install gtk4 webkitgtk6.0`\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eClick here for instructions on 🪟 Windows\u003c/summary\u003e\n  The compiled windows library in this package does not bundle any webview version with itself but rather uses the system installed one.\n\n\u003e To bundle a specific version, see Development section below.\n\nThe \u003ca href=\"https://developer.microsoft.com/en-us/microsoft-edge/webview2/\"\u003eMicrosoft Edge WebView2\u003c/a\u003e runtime is required to be installed on the system for any version of Windows before Windows 11.\nTo manually update or install the latest version, follow the steps \u003ca href=\"https://github.com/MicrosoftEdge/WebView2Feedback/issues/3371#issuecomment-1500917825\"\u003ehere\u003c/a\u003e.\n\n\u003c/details\u003e\n\n```bash\nbun i webview-bun\n```\n\n## Example\n\n```typescript\nimport { Webview } from \"webview-bun\";\n\nconst html = `\n\u003chtml\u003e\n    \u003cbody\u003e\n        \u003ch1\u003eHello from bun v${Bun.version} !\u003c/h1\u003e\n    \u003c/body\u003e\n\u003c/html\u003e\n`;\n\nconst webview = new Webview();\n\nwebview.setHTML(html);\nwebview.run();\n```\n\nFor more examples, browse the `examples` folder of this repository.\n\n## Single-file executable\n\nYou can compile a single self-sufficient executable file for your webview app.\n\nFor example, let's create a single executable for the above To-Do app. Clone this repository and run,\n\n```bash\nbun build --compile --minify --sourcemap ./examples/todoapp/app.ts --outfile todoapp\n```\n\n\u003e [!TIP]  \n\u003e By default, a terminal window will also open in the back when double-click opening the executable in Windows and macOS.\n\u003e\n\u003e #### 🪟 To hide it in Windows:\n\u003e\n\u003e Download [hidecmd.bat](https://github.com/tr1ckydev/webview-bun/blob/main/scripts/hidecmd.bat) from this repository and save in the same folder as the binary. Open terminal there and execute,\n\u003e\n\u003e ```bash\n\u003e .\\hidecmd.bat todoapp.exe\n\u003e ```\n\u003e\n\u003e #### 🍎 To hide it in macOS:\n\u003e\n\u003e Add the extension `.app` in the end of the above bun build command.\n\n### Cross-platform compilation\n\nBun now supports cross-compilation of single executable binaries. To cross compile your webview app for a different platform run,\n\n```bash\nbun build --compile --target=bun-windows-x64 --minify --sourcemap ./examples/todoapp/app.ts --outfile todoapp\n```\n\nSee [full list](https://github.com/oven-sh/bun/blob/main/docs/bundler/executables.md#supported-targets) of supported `target`s.\n\n### Bun.serve with webview\n\nIf you run a web server it will block the main thread, but using workers you can run the webview window on another thread.\n\n[From Bun v1.1.25, you can now embed worker scripts in a standalone executable.](https://bun.sh/blog/bun-v1.1.25#worker-in-standalone-executables) Clone this repository then,\n\n```bash\ncd examples/webserver/\nbun build --compile --minify --sourcemap ./index.ts ./worker.ts --outfile webserver\n```\n\n\u003e [!NOTE]\n\u003e\n\u003e On macOS, this doesn't work due to some bug in bun as webview window doesn't open from a worker.\n\n## Documentation\n\nRefer to the comments in the source code for full documentation.\n\n## Development\n\nPlease format all code with [Prettier](https://prettier.io/) using the root `.prettierrc` configuration. You can run `bun pretty` to automatically format all files if you prefer to not integrated Prettier into your IDE.\n\n### Prerequisites\n\nIn addition to the dependencies mentioned during the Installation section, you will need additional build tools including;\n\n- `cmake`\n- `ninja`\n- `python3`\n\n#### If you are on **Windows,** you need C++ Build Tools.\n- Go to https://visualstudio.microsoft.com/downloads.\n- Scroll down \u003e _All Downloads_ \u003e _Tools for Visual Studio_.\n- Download _Build Tools for Visual Studio 2022_ and run.\n- Select _Desktop development with C++_ and install.\n\n#### Various linux distribution examples:\n- Debian 12\n```\nsudo apt install cmake ninja-build python3 clang-14 clang-format-14 libwebkitgtk-6.0-dev\n```\n- Fedora 40\n```\nsudo dnf install cmake ninja-build python3 clang15 clang-tools-extra webkitgtk6.0-devel\n```\n- Arch\n```\nsudo pacman -S cmake ninja python3 clang14 \n```\n\n### Building\n\n- Clone the repository along with the [webview](https://github.com/webview/webview) submodule.\n\n  ```bash\n  git clone --recurse-submodules https://github.com/tr1ckydev/webview-bun\n  cd webview-bun\n  bun i\n  ```\n\n- Build the library for your platform.\n\n  \u003e Under the hood, it invokes webview's own cmake build system to compile the shared library file.\n\n  ```bash\n  bun run build\n  ```\n\n- (Optional) Clear the build cache.\n\n  ```bash\n  bun clean\n  ```\n\nThe compiled library file can be found inside the `build` folder.\n\n### Customization\n\n🐧 For linux, if you want to use a different WebkitGTK version, change the cmake `WEBVIEW_WEBKITGTK_API` option in _build.ts_ to one of the [available values](https://github.com/webview/webview?tab=readme-ov-file#linux-specific-options). Be sure to first install the corresponding version libraries.\n\n🪟 For windows, if you want to bundle a specific webview version instead of using the system installed one, set the cmake `WEBVIEW_MSWEBVIEW2_VERSION` option to one of the [NuGet version strings](https://www.nuget.org/packages/Microsoft.Web.WebView2/#versions-body-tab).\n\nCheck out the [webview build docs](https://github.com/webview/webview?tab=readme-ov-file#customization) for more options.\n\n### Running\n\n\u003e [!TIP]\n\u003e To use your own webview library, set the `WEBVIEW_PATH` environment variable with the path to your webview shared library file.\n\nRun the following example to see it in action.\n\n```bash\nbun run examples/basic.ts\n```\n\nFor more examples, browse the `examples` folder of this repository.\n\n## Credits\n\nThis repository is a port of [webview_deno](https://github.com/webview/webview_deno) with various changes to work with the bun runtime.\n\n## License\n\nThis repository uses MIT license. See [LICENSE](https://github.com/tr1ckydev/webview-bun/blob/main/LICENSE) for full license text.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftr1ckydev%2Fwebview-bun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftr1ckydev%2Fwebview-bun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftr1ckydev%2Fwebview-bun/lists"}