New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@enymo/react-socket-hook

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@enymo/react-socket-hook

React hook for interacting with a socket.io server

latest
Source
npmnpm
Version
1.1.5
Version published
Maintainers
2
Created
Source

React Socket Hook

A simple hook providing a declarative syntax for listening to websocket events using socket.io

This library was mainly created for use with the React Resource Hook, but can be used by itself nevertheless.

Installation

The library may be installed from npm using

npm i @enymo/react-socket-hook

Usage

In order to use the useSocket hook in your components, you app has to be wrapped with the SocketProvider to configure the hook

import { SocketProvider } from "@enymo/react-socket-hook";
import React from "react";
import { io } from "socket.io-client";

function App() {
    const client = io("https://www.example.com");

    return (
        <SocketProvider value={client}>
            {/* your app here */}
        </SocketProvider>
    )
}

You can then listen to socket events in your components like this:

import React from "react";
import useSocket from "@enymo/react-socket-hook";

export default function Component() {
    useSocket("event", (payload: any) => {
        // do something with payload
    }, []);

    return null;
}

FAQs

Package last updated on 16 Dec 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts