Registry / messaging / larasopp

larasopp

JSON →
library1.2.27jsnpmunverified

Larasopp Client is a WebSocket client for Laravel broadcasting with full TypeScript support. Version 1.2.27 provides type safety for channels, events, and users via generics. It supports public, private, and presence channels with automatic reconnection. Compared to other Laravel WebSocket clients (e.g., Echo), Larasopp offers per-key JSON revivers, typed event caching, and a permission system. The package is actively maintained with regular updates.

npm install larasopp
INSTALL
IMPORT
SIG · LARASOPP
L
larasopp
messagingjavascriptv1.2.27
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Larasopp
import Larasopp from 'larasopp'
import { Larasopp } from 'larasopp'
Default export; named import will not work
Listener
import Larasopp from 'larasopp'; const listener = larasopp.subscribe('chat'); // Listener type is inferred
import { Listener } from 'larasopp'
Listener is not exported; it is returned from subscribe().
IConfig
import Larasopp from 'larasopp'; const config: import('larasopp').IConfig = { host: '...' }
import { IConfig } from 'larasopp'
IConfig is not exported; use type via import() or copy the interface.

Shows how to create a typed Larasopp client, connect, subscribe to a channel, and listen to a typed event.

import Larasopp from 'larasopp'; // Define your channel events structure type ChannelsEvents = { chat: { message: { text: string; author: string; timestamp: number }; typing: { user: string }; }; }; // Define your user type (optional) interface MyUser { id: number; name: string; } // Create typed instance const larasopp = new Larasopp<ChannelsEvents, MyUser>({ host: 'ws://127.0.0.1:3001', token: process.env.WS_TOKEN ?? '', }); // Connect larasopp.connect(); // Subscribe to a channel const listener = larasopp.subscribe('chat'); // Listen for typed events listener.listen('message', (data) => { console.log(`${data.author}: ${data.text}`); });
Debug
Known issues
gotchaIConfig and Listener are not exported; TypeScript support relies on generics but internal types are not importable.
fix
Use typeof or import() to extract types, or define your own interfaces.
affects: >=1.0
gotchaThe `listen` method's `withCache` parameter defaults to `false`. If set to `true`, the callback will be called immediately with cached data if available.
fix
Check if you want caching behavior before enabling withCache=true.
affects: >=1.0
gotchaDefault import only: `import Larasopp from 'larasopp'` works; named imports like `import { Larasopp }` will fail.
fix
Use default import only.
affects: >=1.0
gotchaThe `trigger` method requires `permission` and `waitSubscribe` parameters; omitting them may lead to unexpected behavior.
fix
Always provide explicit permission level (e.g., 'public') and waitSubscribe boolean.
affects: >=1.0
deprecatedNo deprecated features reported yet.
fix
Stay updated with changelog.
affects: >=1.0
Errors
Common errors & fixes
TypeError: larasopp.subscribe is not a function
Forgetting to call connect() before subscribe.
fix
Call larasopp.connect() before subscribing.
Module '"larasopp"' has no exported member 'Larasopp'.
Using named import instead of default import.
fix
Use 'import Larasopp from 'larasopp''.
Argument of type '"chat"' is not assignable to parameter of type 'keyof ChannelsEvents'.
Type parameter for ChannelsEvents incorrect or not provided.
fix
Ensure type argument matches your event structure: new Larasopp<ChannelsEvents>(...)
WebSocket connection to 'ws://...' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
WebSocket server not running or wrong host/port.
fix
Verify server is running and host URL is correct.
Upgrade
Version history
1.2.27latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
17 hits · last 30 days
node
16
OpenAI (training)
1
Resources
larasopp — npm install larasopp · libregistry