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

react-native-smart-socket

v1.0.0

Published

Advanced WebSocket package with file processing, real-time presence, and chat features for React Native

Readme

React Native Smart Socket

Disclaimer: This package is currently in a pre-release stage and is not yet ready for production use. Some of the core functionalities, such as the ConnectionManager and FileProcessor, are mock implementations and need to be replaced with actual logic.

React Native Smart Socket is an advanced WebSocket package for React Native, designed to provide a robust and feature-rich real-time communication solution. It comes with built-in support for file processing, real-time presence, chat features, and much more.

Features

  • WebSocket Management: Automatically manages WebSocket connections, with auto-reconnect and offline support.
  • Real-time Presence: Track user presence and status in real-time.
  • Typing Indicators: Real-time typing indicators for chat applications.
  • Room Management: Easily manage rooms and participants.
  • File Uploads: Built-in support for file uploads with chunking, compression, and progress tracking.
  • Voice Messages: Send and receive voice messages with ease.
  • Custom Hooks: A set of custom hooks to easily integrate the socket functionalities into your React Native components.
  • TypeScript Support: Written in TypeScript for a better developer experience.

Installation

npm install react-native-smart-socket

or

yarn add react-native-smart-socket

Usage

Here is a simple example of how to use the useSmartSocket hook to connect to a WebSocket server.

import React from 'react';
import { View, Text } from 'react-native';
import { useSmartSocket } from 'react-native-smart-socket';

const App = () => {
  const config = {
    url: 'ws://your-socket-server.com',
    userId: 'user-123',
  };

  const { socket, isConnected, connectionError } = useSmartSocket(config);

  return (
    <View>
      <Text>Connection Status: {isConnected ? 'Connected' : 'Disconnected'}</Text>
      {connectionError && <Text>Error: {connectionError.message}</Text>}
    </View>
  );
};

export default App;

API Reference

Hooks

The package provides a set of custom hooks to interact with the WebSocket server.

  • useSmartSocket(config): The main hook to initialize and manage the WebSocket connection.
  • useChat(roomId, socket): A comprehensive hook for building a complete chat experience.
  • useChatMessages(roomId, socket): A hook to manage chat messages in a room.
  • useUserPresence(socket): A hook to track online users.
  • useTypingIndicator(roomId, socket): A hook to manage typing indicators in a room.
  • useRooms(socket): A hook to manage rooms.
  • useFileUpload(socket): A hook for handling file uploads.
  • useFilePicker(): A hook for picking files from the device.
  • useVoiceRecorder(): A hook for recording voice messages.
  • useFileMessages(roomId, socket): A hook to get all file messages in a room.
  • useFileChat(socket): A hook that combines file-related hooks for a streamlined file-based chat experience.
  • useApiWatcher(config, socket): A hook to watch for API updates.

SmartSocketCore Class

The core class that manages the WebSocket connection and all the related functionalities. The useSmartSocket hook returns an instance of this class.

Configuration

The useSmartSocket hook takes a configuration object with the following properties:

| Property | Type | Description | | ---------------- | ----------------- | --------------------------------------------------------------------------- | | url | string | The URL of the WebSocket server. | | userId | string | The ID of the current user. | | username | string | The name of the current user. | | autoConnect | boolean | Whether to automatically connect to the server. Defaults to true. | | reconnect | ReconnectConfig | Configuration for the auto-reconnect feature. | | presence | PresenceConfig | Configuration for the user presence feature. | | typing | TypingConfig | Configuration for the typing indicator feature. | | rooms | string[] | An array of room IDs to automatically join upon connection. | | apiConfig | ApiConfig | Configuration for the API watcher feature. | | fileProcessing | FileProcessingConfig | Configuration for the file processing feature. |

Events

The SmartSocketCore instance emits a number of events that you can listen to using the on method.

  • connected: Fired when the socket is connected.
  • disconnected: Fired when the socket is disconnected.
  • reconnecting: Fired when the socket is trying to reconnect.
  • error: Fired when an error occurs.
  • message: Fired when a new message is received.
  • room_joined: Fired when a user joins a room.
  • room_left: Fired when a user leaves a room.
  • user_joined: Fired when a new user comes online.
  • user_left: Fired when a user goes offline.
  • presence_update: Fired when a user's presence is updated.
  • user_typing: Fired when a user starts or stops typing.
  • file_upload_progress: Fired to report the progress of a file upload.
  • file_upload_complete: Fired when a file upload is complete.
  • file_upload_error: Fired when a file upload fails.

Contributing

Contributions are welcome! Please feel free to submit a pull request or open an issue.

License

This project is licensed under the MIT License.