DocumentationDevice interactionIntegration WalkthroughsHow to ...Use a Transport

Transports

The Device Management Kit is offering several transports to communicate with a Ledger device. Depending on the environment and usecase, you can choose the transport that best suits your needs.

Available transports

TransportDescription
WebHidThe WebHID transport uses the Web HID API (usb) to communicate with a Ledger device.
WebBleThe WebBLE transport uses the Web BLE API (bluetooth) to communicate with a Ledger device.

How to use a transport

Transports are injected in the DeviceManagementKitBuilder before building the Device Management Kit instance. This is done by calling the addTransport method on the builder. You can inject the transport in two different ways:

  • Using the default transport factory provided by the package
  • Using directly the transport creating your own factory (for custom transports or additional configuration…)
import { DeviceManagementKitBuilder } from "@ledgerhq/device-management-kit";
import { WebHidTransport, webHidTransportFactory } from "@ledgerhq/device-transport-kit-web-hid";
 
// Using the default transport factory
const dmk = new DeviceManagementKitBuilder()
  .addTransport(webHidTransportFactory)
  .build();
 
// Using the transport directly
const dmk = new DeviceManagementKitBuilder()
  .addTransport(({
    deviceModelDataSource: DeviceModelDataSource;
    loggerServiceFactory: (tag: string) => LoggerPublisherService;
    config: DmkConfig;
    apduSenderServiceFactory: ApduSenderServiceFactory;
    apduReceiverServiceFactory: ApduReceiverServiceFactory;
  }) => {
    // Some extra code here to configure the transport
    // Then we return the transport instance
    return new WebHidTransport(
      deviceModelDataSource,
      loggerServiceFactory,
      config,
      apduSenderServiceFactory,
      apduReceiverServiceFactory,
    );
  })
  .build();
Ledger
Copyright © Ledger SAS. All rights reserved. Ledger, Ledger Nano S, Ledger Vault, Ledger OS are registered trademarks of Ledger SAS