@molecule/app-network-react-native
v1.0.1
Published
React Native network status provider for molecule.dev (@react-native-community/netinfo)
Maintainers
Readme
@molecule/app-network-react-native
Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit
src/index.tsJSDoc, not this file.
React Native network status provider for molecule.dev.
Uses @react-native-community/netinfo to implement the NetworkProvider
interface from @molecule/app-network: connection status/type, cellular
generation, metered detection, and online/offline/change events.
Quick Start
import { setProvider } from '@molecule/app-network'
import { provider } from '@molecule/app-network-react-native'
setProvider(provider) // once, at app startupType
provider
Installation
npm install @molecule/app-network-react-native @molecule/app-i18n @molecule/app-logger @molecule/app-network @react-native-community/netinfoAPI
Interfaces
ReactNativeNetworkConfig
Configuration for the React Native network provider.
interface ReactNativeNetworkConfig {
/**
* URL to use for active connectivity checks.
* @default 'https://clients3.google.com/generate_204'
*/
connectivityCheckUrl?: string
/**
* Timeout in milliseconds for connectivity checks.
* @default 5000
*/
connectivityCheckTimeout?: number
}Functions
createReactNativeNetworkProvider(config)
Creates a React Native network status provider backed by @react-native-community/netinfo.
function createReactNativeNetworkProvider(config?: ReactNativeNetworkConfig): NetworkProviderconfig— Optional provider configuration.
Returns: A NetworkProvider implementation for React Native.
Constants
provider
Default React Native network status provider.
const provider: NetworkProviderCore Interface
Implements @molecule/app-network interface.
Bond Wiring
Setup function to register this provider with the core interface:
import { setProvider } from '@molecule/app-network'
import { provider } from '@molecule/app-network-react-native'
export function setupNativeNetworkReactNative(): void {
setProvider(provider)
}Injection Notes
Requirements
Peer dependencies:
@molecule/app-i18n^1.0.1@molecule/app-logger^1.0.1@molecule/app-network^1.0.1@react-native-community/netinfo>=9.0.0
Runtime Dependencies
@molecule/app-i18n@molecule/app-logger@molecule/app-network@react-native-community/netinfoInstall the
@react-native-community/netinfopeer (>= 9). It is imported lazily: without it every call rejects with an install hint, andonChange/onOnline/onOfflinefail to attach (surface as an unhandled rejection) — callawait getStatus()once at startup to fail fast.checkConnectivity()performs an active HTTP HEAD probe — by default tohttps://clients3.google.com/generate_204. PointconnectivityCheckUrl(or the per-callurlargument) at your own endpoint if third-party egress is a concern.getCapabilities(): connection type, cellular generation, and metered detection are supported; speed estimation is not.
Translations
Translation strings are provided by @molecule/app-locales-network.
