https://github.com/swiftwasm/javascriptkit
Swift framework to interact with JavaScript through WebAssembly.
https://github.com/swiftwasm/javascriptkit
javascript swift swiftwasm webassembly
Last synced: about 2 months ago
JSON representation
Swift framework to interact with JavaScript through WebAssembly.
- Host: GitHub
- URL: https://github.com/swiftwasm/javascriptkit
- Owner: swiftwasm
- License: mit
- Created: 2020-03-04T07:10:29.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2025-05-12T23:00:22.000Z (about 2 months ago)
- Last Synced: 2025-05-13T00:18:40.312Z (about 2 months ago)
- Topics: javascript, swift, swiftwasm, webassembly
- Language: Swift
- Homepage: https://swiftpackageindex.com/swiftwasm/JavaScriptKit/documentation/javascriptkit
- Size: 3.94 MB
- Stars: 750
- Watchers: 17
- Forks: 51
- Open Issues: 22
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# JavaScriptKit
[](https://github.com/swiftwasm/JavaScriptKit/actions/workflows/test.yml)
[](https://swiftpackageindex.com/swiftwasm/JavaScriptKit/documentation)Swift framework to interact with JavaScript through WebAssembly.
## Quick Start
Check out the [Hello World](https://swiftpackageindex.com/swiftwasm/JavaScriptKit/tutorials/javascriptkit/hello-world) tutorial for a step-by-step guide to getting started.
## Overview
JavaScriptKit provides a seamless way to interact with JavaScript from Swift code when compiled to WebAssembly. It allows Swift developers to:
- Access JavaScript objects and functions
- Create closures that can be called from JavaScript
- Convert between Swift and JavaScript data types
- Use JavaScript promises with Swift's `async/await`
- Work with multi-threading```swift
import JavaScriptKit// Access global JavaScript objects
let document = JSObject.global.document// Create and manipulate DOM elements
var div = document.createElement("div")
div.innerText = "Hello from Swift!"
_ = document.body.appendChild(div)// Handle events with Swift closures
var button = document.createElement("button")
button.innerText = "Click me"
button.onclick = .object(JSClosure { _ in
JSObject.global.alert!("Button clicked!")
return .undefined
})
_ = document.body.appendChild(button)
```Check out the [examples](https://github.com/swiftwasm/JavaScriptKit/tree/main/Examples) for more detailed usage.
## Contributing
Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to the project.
## Sponsoring
[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.