Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lightweight-socket

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lightweight-socket

lightweight socket

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

Lightweight Socket

Lightweight Socket is a minimal, lightweight, and efficient real-time communication library for Node.js and the browser. It is inspired by Socket.IO but aims to provide a simpler and more streamlined API.

Features

  • Real-time bi-directional communication between server and client
  • Lightweight and efficient
  • Supports both Node.js and browser environments
  • Simple and easy-to-use API

Installation

You can install Lightweight Socket via npm:

npm install lightweight-socket

Usage

Server (Node.js)

import { Server } from 'lightweight-socket'

const server = new Server({ port: 3000 });

server.on('connection', (client) => {
    console.log('A client connected');

    client.on('message', (data) => {
        console.log('Received message from client:', data);
    });
});

Client (Browser)

import { BrowserClient } from 'lightweight-socket';

const client = new BrowserClient('ws://localhost:3000');

client.on('connect', () => {
    console.log('Connected to server');

    client.emit('message', 'Hello, server!');
});

Building

To build the server and browser versions of the library, run:

npm run build

Contributing

Contributions are welcome! Please feel free to submit a pull request.

License

Lightweight Socket is open source software licensed as MIT.

Disclaimer

This library is inspired by Socket.IO but is not affiliated with or endorsed by the Socket.IO team. It aims to provide a lightweight alternative for real-time communication in Node.js and browser environments.

Keywords

FAQs

Package last updated on 18 May 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc