JavaScript interoperability
The Dart web platform supports communication with JavaScript apps and libraries, as well as browser APIs, using dart:js_interop
.
Web developers can benefit from using external JS libraries in their Dart code, without having to rewrite anything in Dart.
Next-generation JS interop
#The Dart team recently overhauled the collection of features and APIs that allow developers access to JavaScript and browser bindings in their Dart code. This next generation of web interop not only improves user experience, but also enables Wasm support, aligning Dart with the future of the Web.
The following table maps Dart's new JS and web interop solutions to their past counterparts:
New interop libraries | Previous libraries |
---|---|
package:web | dart:html dart:indexed_db dart:svg dart:web_audio dart:web_gl |
dart:js_interop dart:js_interop_unsafe | package:js dart:js dart:js_util |
The Dart interop story has been under heavy development for some time now; check out the Past JS interop page for a more in depth summary on past iterations.
Overview
#For information on how to write and use JavaScript interop:
For information on interacting with web APIs:
For tutorials and help:
For information on previous JavaScript interop libraries:
For additional documentation on JavaScript interop:
Unless stated otherwise, the documentation on this site reflects Dart 3.5.3. Page last updated on 2024-08-04. View source or report an issue.