Skip to main content

JavaScript interoperability

Integrate JavaScript code into your Dart web app.

Integrate JavaScript libraries and APIs into Dart web apps.

Overview

#

The Dart web platform provides tools to call JavaScript from Dart and Dart from JavaScript, bringing the JavaScript ecosystem directly to Dart code.

Find getting-started resources, usage guides, and dart:js_interop library documentation for calling JavaScript libraries, interacting with browser APIs, and compiling web apps to WebAssembly (Wasm).

Get started with JS interop:

Review the reference guides:

Interact with the browser:

WebAssembly (dart2wasm) support

#

When compiling Dart web apps to WebAssembly (dart compile wasm), keep these interoperability and performance practices in mind:

  • Use dart:js_interop and package:web: Deprecated legacy web and interop libraries (dart:html, dart:js, dart:js_util, and package:js) are unsupported on Wasm targets.
  • Minimize high-frequency calls across the Wasm and JS boundary: In performance-critical code or tight loops, keep computation in Dart or batch values rather than making repeated interop calls per iteration.
  • Find Wasm-compatible packages: Use the wasm-ready filter on pub.dev to verify that packages use dart:js_interop and package:web.

Additional resources

#

Explore previous JavaScript interop libraries:

Explore the API reference documentation: