flutter_js_bridger library

Flutter JS Bridger — Use any npm package in your Flutter/Dart projects.

Provides a seamless bridge between Dart and the JavaScript ecosystem. Install, load, and use any npm package directly from Dart with natural, idiomatic syntax.

Cross-platform: Works on Desktop (Node.js), Web (dart:js_interop), iOS/macOS (JavaScriptCore FFI), and Android (QuickJS FFI).

# Terminal — manage packages once:
dart run flutter_js_bridger init
dart run flutter_js_bridger add lodash
import 'package:flutter_js_bridger/flutter_js_bridger.dart';

void main() async {
  final js = JsBridge();
  await js.initialize();  // reads js_bridger.json, verifies deps

  dynamic _ = await js.require('lodash');
  var chunks = await _.chunk([1, 2, 3, 4, 5], 2);
  print(chunks); // [[1, 2], [3, 4], [5]]

  await js.dispose();
}

Classes

CallbackManager
Tracks registered Dart callbacks for JS→Dart invocations.
EngineConfig
Configuration for creating a JS engine.
EngineCrashEvent
Emitted when the engine process crashes.
EngineEvent
Events emitted by the engine for lifecycle monitoring.
EngineReadyEvent
Emitted when the engine is ready for requests.
EngineRestartEvent
Emitted when the engine successfully restarts after a crash.
InProcessEngine
Base class for engines that run JS in the same process.
JsBridge
Main entry point — bridges Dart to the JavaScript/npm ecosystem.
JsBridgeConfig
Configuration options for JsBridge.
JsBridgerManifest
Represents a js_bridger.json manifest file.
JsBundler
Bundles npm packages into a single JS file for web/mobile deployment.
JsChain
A lazy chaining proxy that accumulates a property access path.
JsEngine
Abstract interface every JS engine must implement.
JsObject
A Dart proxy for a JavaScript object living in the Node.js worker.
NodeEngine
Node.js subprocess engine for desktop platforms.
PackageManager
Manages npm packages in the bridge working directory.

Enums

JsErrorCode
Error codes covering all failure scenarios.

Exceptions / Errors

JsBridgeException
Base exception for all flutter_js_bridger errors.
JsModuleException
Thrown when a JS module cannot be found (require fails).
JsPackageException
Thrown when npm install/remove/update fails.
JsReferenceException
Thrown when a JS object reference is no longer valid.
JsRuntimeException
Thrown when the Node.js runtime cannot be found or started.
JsTimeoutException
Thrown when a request to the worker times out.
JsTypeException
Thrown for JS TypeError (not a function, not a constructor, etc).