{"id":16221548,"url":"https://github.com/swiftwasm/javascriptkit","last_synced_at":"2026-02-05T11:10:53.555Z","repository":{"id":38383613,"uuid":"244832006","full_name":"swiftwasm/JavaScriptKit","owner":"swiftwasm","description":"Swift framework to interact with JavaScript through WebAssembly.","archived":false,"fork":false,"pushed_at":"2025-05-12T23:00:22.000Z","size":4127,"stargazers_count":750,"open_issues_count":22,"forks_count":51,"subscribers_count":17,"default_branch":"main","last_synced_at":"2025-05-13T00:18:40.312Z","etag":null,"topics":["javascript","swift","swiftwasm","webassembly"],"latest_commit_sha":null,"homepage":"https://swiftpackageindex.com/swiftwasm/JavaScriptKit/documentation/javascriptkit","language":"Swift","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/swiftwasm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","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,"zenodo":null},"funding":{"github":["swiftwasm"],"patreon":null,"open_collective":"swiftwasm","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2020-03-04T07:10:29.000Z","updated_at":"2025-05-12T23:00:25.000Z","dependencies_parsed_at":"2025-05-13T00:28:50.969Z","dependency_job_id":null,"html_url":"https://github.com/swiftwasm/JavaScriptKit","commit_stats":{"total_commits":369,"total_committers":16,"mean_commits":23.0625,"dds":0.4363143631436315,"last_synced_commit":"384d6686939a0ab7103b00ab942b3a3edc7f46e3"},"previous_names":["kateinoigakukun/javascriptkit"],"tags_count":45,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiftwasm%2FJavaScriptKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiftwasm%2FJavaScriptKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiftwasm%2FJavaScriptKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiftwasm%2FJavaScriptKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swiftwasm","download_url":"https://codeload.github.com/swiftwasm/JavaScriptKit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254471061,"owners_count":22076585,"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":["javascript","swift","swiftwasm","webassembly"],"created_at":"2024-10-10T12:08:44.720Z","updated_at":"2026-02-03T09:12:30.874Z","avatar_url":"https://github.com/swiftwasm.png","language":"Swift","funding_links":["https://github.com/sponsors/swiftwasm","https://opencollective.com/swiftwasm","https://github.com/sponsors/swiftwasm/"],"categories":[],"sub_categories":[],"readme":"# JavaScriptKit\n\n[![Run unit tests](https://github.com/swiftwasm/JavaScriptKit/actions/workflows/test.yml/badge.svg)](https://github.com/swiftwasm/JavaScriptKit/actions/workflows/test.yml)\n[![Documentation](https://img.shields.io/badge/docc-read_documentation-blue)](https://swiftpackageindex.com/swiftwasm/JavaScriptKit/documentation)\n\nSwift framework to interact with JavaScript through WebAssembly.\n\n## Quick Start\n\nCheck out the [Hello World](https://swiftpackageindex.com/swiftwasm/JavaScriptKit/tutorials/javascriptkit/hello-world) tutorial for a step-by-step guide to getting started.\n\n## Overview\n\nJavaScriptKit provides a seamless way to interact with JavaScript from Swift code when compiled to WebAssembly. It allows Swift developers to:\n\n- Access JavaScript objects and functions\n- Create closures that can be called from JavaScript\n- Convert between Swift and JavaScript data types\n- Use JavaScript promises with Swift's `async/await`\n- Work with multi-threading\n\n```swift\nimport JavaScriptKit\n\n// Access global JavaScript objects\nlet document = JSObject.global.document\n\n// Create and manipulate DOM elements\nvar div = document.createElement(\"div\")\ndiv.innerText = \"Hello from Swift!\"\n_ = document.body.appendChild(div)\n\n// Handle events with Swift closures\nvar button = document.createElement(\"button\")\nbutton.innerText = \"Click me\"\nbutton.onclick = .object(JSClosure { _ in\n    JSObject.global.alert!(\"Button clicked!\")\n    return .undefined\n})\n_ = document.body.appendChild(button)\n```\n\n**Learn more:** [JavaScript Interop Cheat Sheet](https://swiftpackageindex.com/swiftwasm/JavaScriptKit/documentation/javascriptkit/javascript-interop-cheat-sheet)\n\n## BridgeJS Plugin\n\n\u003e **Note:** BridgeJS is experimental. APIs may change in future releases.\n\nBridgeJS provides easy interoperability between Swift and JavaScript/TypeScript. It enables:\n\n- **Exporting Swift APIs to JavaScript**: Make your Swift code callable from JavaScript\n- **Importing TypeScript APIs into Swift**: Use JavaScript APIs with type safety in Swift\n\nFor architecture details, see the [BridgeJS Plugin README](Plugins/BridgeJS/README.md).\n\n### Exporting Swift to JavaScript\n\nMark Swift code with `@JS` to make it callable from JavaScript:\n\n```swift\nimport JavaScriptKit\n\n@JS class Greeter {\n    @JS var name: String\n\n    @JS init(name: String) {\n        self.name = name\n    }\n\n    @JS func greet() -\u003e String {\n        return \"Hello, \\(name)!\"\n    }\n}\n```\n\n**JavaScript usage:**\n```javascript\nconst greeter = new exports.Greeter(\"World\");\nconsole.log(greeter.greet()); // \"Hello, World!\"\n```\n\n**Learn more:** [Exporting Swift to JavaScript](https://swiftpackageindex.com/swiftwasm/JavaScriptKit/documentation/javascriptkit/exporting-swift-to-javascript)\n\n### Importing TypeScript into Swift\n\nDefine TypeScript interfaces and BridgeJS generates type-safe Swift bindings:\n\n```typescript\n// bridge-js.d.ts\ninterface Document {\n    title: string;\n    getElementById(id: string): HTMLElement;\n    createElement(tagName: string): HTMLElement;\n}\n\nexport function getDocument(): Document;\n```\n\n**Swift usage:**\n```swift\n@JS func run() throws(JSException) {\n    let document = try getDocument()\n    try document.setTitle(\"My Swift App\")\n    let button = try document.createElement(\"button\")\n    try button.setInnerText(\"Click Me\")\n}\n```\n\n**Learn more:** [Importing TypeScript into Swift](https://swiftpackageindex.com/swiftwasm/JavaScriptKit/documentation/javascriptkit/importing-typescript-into-swift)\n\n### Try It Online\n\nUse the [BridgeJS Playground](https://swiftwasm.org/JavaScriptKit/PlayBridgeJS/) to preview what interfaces will be exposed on the Swift/TypeScript sides.\n\n## Examples\n\nCheck out the [examples](https://github.com/swiftwasm/JavaScriptKit/tree/main/Examples) for more detailed usage patterns.\n\n## Contributing\n\nContributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to the project.\n\n## Sponsoring\n\n[Become a gold or platinum sponsor](https://github.com/sponsors/swiftwasm/) and contact maintainers to add your logo on our README on Github with a link to your site.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswiftwasm%2Fjavascriptkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswiftwasm%2Fjavascriptkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswiftwasm%2Fjavascriptkit/lists"}