npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

netsignal

v1.0.0

Published

Ultra-fast network state for React Native 0.80+ (New Architecture)

Downloads

9

Readme

NetSignal

Ultra-fast network state detection for React Native 0.80+ New Architecture

GitHub React Native Platform TypeScript

0.3ms latency • TurboModule powered • Android-first • Production ready

Features

  • Lightning fast - 0.3ms response time via TurboModule
  • New Architecture - Built for React Native 0.80+
  • Production ready - Comprehensive error handling and thread safety
  • Multiple connections - Detects WiFi + Ethernet redundancy
  • React hooks - Clean integration with React components
  • Zero dependencies - No external runtime dependencies

Requirements

  • React Native 0.80.0 or higher
  • New Architecture enabled (newArchEnabled=true)
  • Android only (iOS support planned for v1.1.0)
  • Kotlin 1.9+ for compilation

Installation

npm install netsignal

Setup

  1. Enable New Architecture in android/gradle.properties:
newArchEnabled=true
  1. Add package to MainApplication.kt:
import com.netsignal.NetSignalTurboPackage

override fun getPackages(): List<ReactPackage> = listOf(
    // ... other packages
    NetSignalTurboPackage()
)
  1. Add permission to AndroidManifest.xml:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Basic Usage

import NetSignal, { useNetworkState } from 'netsignal';

// Synchronous methods (0.3ms each)
const isOnline = NetSignal.isConnected();
const networkType = NetSignal.getConnectionType(); // "wifi" | "cellular" | "ethernet" | "none"
const connectionCount = NetSignal.getActiveConnectionCount();
const hasBackup = NetSignal.hasMultipleConnections();

// React hook
function NetworkStatus() {
  const network = useNetworkState();

  return (
    <Text>
      {network.connected ? `Online via ${network.type}` : 'Offline'}
      {network.multipleConnections && ' (Backup available)'}
    </Text>
  );
}

API Reference

Synchronous Methods

| Method | Return Type | Description | |--------|-------------|-------------| | isConnected() | boolean | Internet connectivity status | | getConnectionType() | string | Connection type: wifi/cellular/ethernet/none | | getActiveConnectionCount() | number | Number of active connections | | hasMultipleConnections() | boolean | Whether multiple connections exist | | getSimpleSummary() | object | All network info in one call |

Async Methods

const connections = await NetSignal.getAllActiveConnections();
// Returns: { connections: [{ type: "wifi", hasInternet: true, isMetered: false }] }

Events

const unsubscribe = NetSignal.addEventListener((event) => {
  console.log('Network changed:', event.isConnected, event.type);
});

// Cleanup
unsubscribe();

React Hooks

const network = useNetworkState();      // Complete network state
const connected = useIsConnected();     // Just connectivity boolean
const type = useConnectionType();       // Just connection type

Performance

All synchronous calls complete in 0.3-0.5ms:

console.time('check');
NetSignal.isConnected();
console.timeEnd('check');
// Typical result: ~0.3ms

Why fast:

  • Direct TurboModule JSI calls
  • No bridge serialization
  • Native Android system APIs
  • No async overhead for sync methods

Error Handling

NetSignal handles all error cases gracefully:

  • Missing ACCESS_NETWORK_STATE permission → returns safe defaults, logs warning
  • No ConnectivityManager available → returns false/none
  • Network API failures → returns default values
  • Never crashes your app

TypeScript Support

Full type safety:

import NetSignal, {
  ConnectionType,    // "wifi" | "cellular" | "ethernet" | "none" | "unknown"
  NetworkState,      // { connected: boolean, type: string, connectionCount: number, multipleConnections: boolean }
  Connection,        // { type: string, hasInternet: boolean, isMetered: boolean }
  NetworkChangeEvent // { isConnected: boolean, type: string, connectionCount: number }
} from 'netsignal';

Architecture

netsignal/
├── android/src/main/java/com/netsignal/
│   ├── NetSignalTurboModule.kt      (~170 lines) - Core implementation
│   ├── NetSignalTurboPackage.kt     (~25 lines)  - Package registration
│   └── NativeNetSignalSpec.kt       (~20 lines)  - Abstract base
├── src/
│   ├── NativeNetSignal.ts           (~25 lines)  - Codegen spec
│   └── index.tsx                    (~110 lines) - TypeScript wrapper + hooks
└── package.json

Total: ~350 lines

Migration

From @react-native-community/netinfo

- import NetInfo from '@react-native-community/netinfo';
+ import NetSignal, { useNetworkState } from 'netsignal';

- const netInfo = await NetInfo.fetch();
+ const isConnected = NetSignal.isConnected(); // Instant!

- NetInfo.addEventListener(callback);
+ const unsubscribe = NetSignal.addEventListener(callback);

Real-World Example

// POS payment system
async function processPayment(amount: number) {
  // Instant connectivity check (0.3ms)
  if (!NetSignal.isConnected()) {
    throw new Error('No internet connection');
  }

  // Prefer ethernet for stability
  if (NetSignal.getConnectionType() === 'ethernet') {
    console.log('Using stable wired connection');
  }

  // Verify backup connectivity
  if (NetSignal.hasMultipleConnections()) {
    console.log('Backup connection available');
  }

  return await submitPayment(amount);
}

Contributing

See CONTRIBUTING.md for development setup and guidelines.

License

MIT © Anivar Aravind