npm.io
3.2.0 • Published 2d ago

@ledgerhq/live-network

Licence
Apache-2.0
Version
3.2.0
Deps
3
Size
114 kB
Vulns
0
Weekly
0

live-network

Status: DEPRECATED Inside Ledger Live, use RTK Query instead. Outside Ledger Live, use plain fetch or axios directly. This package was extracted to ts-libs to unblock the migration of its dependents, not because it is the recommended path. No new consumers, please.

@ledgerhq/live-network is the shared network layer for Ledger Live. It wraps the underlying HTTP client with Ledger-specific logging, error normalisation, and request optimisation utilities so all services in the monorepo make network calls consistently.

What it does

  • Exposes a network() helper that wraps axios with automatic logging (via @ledgerhq/logs) and maps HTTP errors into typed Ledger errors.
  • Provides a request batcher (batcher/) that coalesces concurrent requests for the same resource into a single in-flight call, reducing redundant network traffic.
  • Provides a cache layer (cache.ts) for memoising responses with configurable TTL.

Key exports / concepts

  • Default export network(options) — drop-in replacement for axios with logging and error handling.
  • seconds(n) / minutes(n) / hours(n) — helpers that produce CacheOptions for use with lru-cache.
  • makeBatcher(request, params) — batches concurrent calls within the same event-loop tick into a single upstream request (via @ledgerhq/live-network/batcher).

Usage context

Used throughout libs/ledger-live-common, coin modules, and service clients. Both desktop and mobile depend on it transitively. It is the single place to configure global request behaviour (timeouts, base URLs via @ledgerhq/live-env).

Keywords