{"id":20484049,"url":"https://github.com/nuxy/go-webview-app-builder","last_synced_at":"2026-05-15T01:23:29.224Z","repository":{"id":229539684,"uuid":"776979897","full_name":"nuxy/go-webview-app-builder","owner":"nuxy","description":":window: Create a JavaScript single-page application (SPA) in a WebView","archived":false,"fork":false,"pushed_at":"2024-05-09T18:06:42.000Z","size":385,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-05-09T19:28:54.406Z","etag":null,"topics":["compiler","desktop-application","golang","single-page-app","webview"],"latest_commit_sha":null,"homepage":"","language":"Go","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/nuxy.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":"2024-03-25T00:18:30.000Z","updated_at":"2024-06-19T12:32:02.925Z","dependencies_parsed_at":"2024-03-25T02:55:21.140Z","dependency_job_id":"a329f531-8919-48bb-8429-f8abea2726f5","html_url":"https://github.com/nuxy/go-webview-app-builder","commit_stats":null,"previous_names":["nuxy/go-webview-app-builder"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuxy%2Fgo-webview-app-builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuxy%2Fgo-webview-app-builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuxy%2Fgo-webview-app-builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuxy%2Fgo-webview-app-builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nuxy","download_url":"https://codeload.github.com/nuxy/go-webview-app-builder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242058218,"owners_count":20065066,"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":["compiler","desktop-application","golang","single-page-app","webview"],"created_at":"2024-11-15T16:19:42.901Z","updated_at":"2026-05-15T01:23:29.213Z","avatar_url":"https://github.com/nuxy.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WebView App Builder [![](https://img.shields.io/badge/go%20report-A+-brightgreen.svg?style=flat)](https://goreportcard.com/report/github.com/nuxy/go-webview-app-builder) [![](https://img.shields.io/github/v/release/nuxy/go-webview-app-builder)](https://github.com/nuxy/go-webview-app-builder/releases) [![NO AI](https://raw.githubusercontent.com/nuxy/no-ai-badge/master/badge.svg)](https://github.com/nuxy/no-ai-badge)\n\nCreate a JavaScript [single-page application](https://en.wikipedia.org/wiki/Single-page_application) (SPA) in a [WebView](https://en.wikipedia.org/wiki/WebView)\n\n![Preview](https://raw.githubusercontent.com/nuxy/go-webview-app-builder/master/example.png)\n\n## The Problem\n\nDue to browser [Cross-origin resource sharing](https://www.w3.org/TR/2020/SPSD-cors-20200602) (CORS) restrictions WebView application sources and related data **must be served from a privileged authority** that defines a properly configured `Access-Control-Allow-Origin` header. In an embedded source application, where HTTP sources are served locally, the WebView uses an unprivileged authority `about:blank` that results with errors when using [Fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch), [Storage](https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API), or [Cookie Store](https://developer.mozilla.org/en-US/docs/Web/API/Cookie_Store) APIs.\n\nThis package does the following to workaround this:\n\n1. Provides [interfaces](https://github.com/nuxy/go-webview-app-builder/blob/develop/app/examples/aurelia/src/webview) to bridge communication between JavaScript [_senders_](https://github.com/nuxy/go-webview-app-builder?tab=readme-ov-file#javascript-sender-example) and Go app [_receivers_](https://github.com/nuxy/go-webview-app-builder?tab=readme-ov-file#go-app-receiver-example).\n2. Embeds all fonts, images, sounds, etc.. as [Base64](https://en.wikipedia.org/wiki/Base64) encoded strings to be used in CSS/JavaScript includes.\n3. Transpiles SPA sources to a single file bundle which is front-loaded on Go application initialization using [`data:`](https://developer.mozilla.org/en-US/docs/web/http/basics_of_http/data_urls)\n4. Compiles Go application and packages SPA sources into a small, self contained binary.\n\nThis creates a fast loading, dynamically-driven, desktop application running your favorite SPA framework.\n\n## Dependencies\n\n- [Go](https://golang.org)\n- [Node.js](https://nodejs.org)\n\n### Debian/Ubuntu\n\nThe following dependencies are required in order to build for Debian-based operating systems.  For alternate OS's (e.g. BSD, Windows) refer to the [webview preqequisites](https://github.com/webview/webview?tab=readme-ov-file#prerequisites) install instructions.\n\n    $ apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev\n\n## Quick and Easy\n\nTranspile the SPA, compile the Go application, and run the example in one command:\n\n    $ make\n\n## Build from source\n\nInstall the new build using [gmake](https://www.gnu.org/software/make).\n\n    $ make install\n\nCross-compile to support [Windows](https://golang.org/dl/go1.15.6.windows-amd64.msi), [OSX](https://golang.org/dl/go1.15.6.darwin-amd64.pkg), [etc](https://golang.org/dl) ..\n\n    $ make build-\u003cdarwin|linux|windows\u003e\n\nNote: Using `--debug` will enable WebView browser [Developer Tools](https://developer.mozilla.org/en-US/docs/Learn/Common_questions/Tools_and_setup/What_are_browser_developer_tools) and development mode in the JavaScript application.\n\n### Building the JavaScript app\n\nInstall the [Node.js](https://nodejs.org) application dependencies using [NPM](https://npmjs.com):\n\n    $ make webview-app-install\n\nTranspile ES2017 sources (using [TypeScript](https://www.typescriptlang.org/docs/handbook/compiler-options.html)) and minify to a distribution:\n\n    $ make webview-app-build\n\n## Running the application\n\nOnce compiled it should be as easy as..\n\n    $ webview-app\n\n## Go application structure\n\n```text\napp                              // SPA sources (Aurelia 2 framework example)\napp/examples/aurelia/index.tmpl  // File to be imported into the WebView (via webview_go)\napp/examples/aurelia/src/webview // JS libraries (Go app bindings, e.g. senders)\nlib                              // Go package dependencies.\napp.go                           // main (Go app bindings, e.g receivers)\n```\n\n## Supported app bindings\n\nThe following `window` [functions](https://github.com/nuxy/go-webview-app-builder/tree/develop/app/src/webview) are accessible when the app is executed in a Go context.  When run using [NPM](https://docs.npmjs.com/cli/v7/commands/npm-start) the functions fallback to local equivalents, if supported.\n\n| Name                     | Description                                 | Fallback    |\n|--------------------------|---------------------------------------------|-------------|\n| `browser_AppVersion`     | Returns the Go application defined version. | N/A         |\n| `browser_HttpGet`        | Make HTTP GET request to a remote source.   | [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) |\n| `browser_HttpHead`       | Make HTTP HEAD request to a remote source.  | Fetch API   |\n| `browser_HttpPost`       | Make HTTP POST request to a remote source.  | Fetch API   |\n| `browser_Navigate`       | Store data that references current screen.  | N/A         |\n| `browser_OpenExtBrowser` | Opens URL in an external web browser.       | N/A         |\n| `browser_StorageDelete`  | Removes stored item from in-memory cache.   | [Storage API](https://developer.mozilla.org/en-US/docs/Web/API/Storage_API) |\n| `browser_StorageSet`     | Add data to be stored in-memory cache.      | Storage API |\n| `browser_StorageGet`     | Returns data from in-memory cache.          | Storage API |\n| `browser_Terminate`      | Close the WebView (terminate session).      | N/A         |\n\n## Usage\n\nThe following illustrates the most typical use case.\n\n```javascript\nimport {AppRequest} from './webview/http';\nimport {AppStorage} from './webview/storage';\n\n// Fetch remote resource..\nconst appReq = new AppRequest();\nconst result = await appReq.get('https://domain.com/api');\nconst {Status, Headers, Body} = result;\n\n// parse result, cache locally.\nconst value = JSON.parse(Body).uuid;\n\nawait AppStorage.set('api-uuid', value);\n\n// .. and later in code\nconst uuid = AppStorage.get('api-uuid');\n```\n\n## Adding custom bindings\n\n### Go app receiver example\n\n```go\nimport \"github.com/nuxy/go-webview-app-builder/lib\"\n\n// Browser settings (defaults).\nvar settings = lib.BrowserSettings{\n    Title:  \"WebView App\",\n    Height: 768,\n    Width:  1024,\n    Resize: true,\n    Debug:  false,\n}\n\nfunc main() {\n    browser := lib.NewBrowser('\u003chtml\u003e\u003c/html\u003e', settings)\n\n    // Concatenate string arguments and return result to JavaScript sender.\n    browser.BindFuncReturn(\"browser_ConcatStrings\", func(arg ...string) string {\n        return arg[0] + arg[1] + arg[2]\n    })\n\n    // Pass arguments to Go function. Returns nothing to JavaScript sender.\n    browser.BindFuncVoid(\"browser_ProcessString\", func(arg ...string) {\n        myCustomFunction(arg[0])\n    })\n\n    ...\n}\n```\n\n### JavaScript sender example\n\n```javascript\nimport {webViewBindExists} from './webview/utils';\n\n// Concatenate string arguments.\nasync function concatStrings(v1, v2, v3) {\n  const bindingName = 'browser_ConcatStrings';\n\n  if (webViewBindExists(bindingName)) {\n    return await window[bindingName](v1, v2, v3);\n  }\n\n  throw new Error(`Go receiver \"${bindingName}\" doesn't exist`);\n}\n\n// Process the string argument.\nasync function executeAndVoid(v) {\n  const bindingName = 'browser_ProcessString';\n\n  if (webViewBindExists(bindingName)) {\n    return await window[bindingName](v);\n  }\n\n  throw new Error(`Go receiver \"${bindingName}\" doesn't exist`);\n}\n```\n\n## Does this support other JavaScript frameworks?\n\n**It should**, as long as the following requirements are met:\n\n1. The application uses [TypeScript](https://www.typescriptlang.org), [Jest](https://jestjs.io), and [Webpack](https://webpack.js.org).  See [`tsconfig`](https://github.com/nuxy/go-webview-app-builder/blob/master/app/tsconfig.json) and [`webpack.config`](https://github.com/nuxy/go-webview-app-builder/blob/master/app/webpack.config.js) for build details.\n2. Assets are encoded as [Base64 data URI](https://en.wikipedia.org/wiki/Data_URI_scheme) and embed in its corresponding import (e.g. [Script](https://github.com/nuxy/go-webview-app-builder/blob/master/app/src/screens/game-images.js]), [Style Sheet](https://github.com/nuxy/go-webview-app-builder/blob/master/app/src/resources/partials/_fonts.scss), HTML)\n3. Webpack writes application _output to a single bundle_ file `/dist/main.bundle.js` which is [parsed by Go](https://github.com/nuxy/go-webview-app-builder/blob/master/app.go#L41).\n4. The [webview JavaScript libraries](https://github.com/nuxy/go-webview-app-builder/tree/master/app/src/webview) and related [tests](https://github.com/nuxy/go-webview-app-builder/tree/master/app/test/unit/webview) exist in their current respective locations.\n\n## References\n\n- [webview_go](https://github.com/webview/webview_go) - Go language binding for the webview library.\n\n## Contributions\n\nIf you fix a bug, or have a code you want to contribute, please send a pull-request with your changes. (Note: Before committing your code please ensure that you run [golint](https://github.com/golang/lint) and [gofmt](https://pkg.go.dev/cmd/gofmt) on contributed files).\n\n## Versioning\n\nThis package is maintained under the [Semantic Versioning](https://semver.org) guidelines.\n\n## License and Warranty\n\nThis package is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.\n\n_go-webview-app-builder_ is provided under the terms of the [MIT license](http://www.opensource.org/licenses/mit-license.php)\n\n## Author\n\n[Marc S. Brooks](https://github.com/nuxy)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnuxy%2Fgo-webview-app-builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnuxy%2Fgo-webview-app-builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnuxy%2Fgo-webview-app-builder/lists"}