emitra-js
v2.0.5
Published
Free lightweight real-time WebSocket client for event-driven apps
Maintainers
Readme
⚡ Emitra
Free, lightweight real-time WebSocket client for building event-driven applications.
100% Free Forever — no credit card, no trial limits. Get your free App Key at evnt-flow.com and start streaming events in minutes.
🚀 Installation
npm install emitra-js🔑 Get Your Free App Key
- Go to evnt-flow.com
- Create a free account
- Copy your App Key from the dashboard
- Use it in the code below — that's it!
⚡ Quick Start
import Emitra from 'emitra-js'
const ef = new Emitra('YOUR_APP_KEY')
const channel = ef.subscribe('my-channel')
// Listen for incoming messages from OTHER clients
// Note: sender does NOT receive their own messages
channel.on('my-event', (data) => {
console.log('Received:', data)
})
// Send a message — other subscribers will receive it
channel.trigger('my-event', { message: 'hello world' })⚠️ Important: The sender does not receive their own messages. Only other subscribers on the same channel will receive them. To test, open two browser tabs or run two Node.js processes.
🌐 Browser Usage
<script src="https://cdn.socket.io/4.8.1/socket.io.min.js"></script>
<script src="https://cdn.evnt-flow.com/emitra/v1/emitra.min.js"></script>
<script>
const ef = new Emitra('YOUR_APP_KEY')
const channel = ef.subscribe('my-channel')
channel.on('my-event', (data) => {
console.log('Received:', data)
})
channel.trigger('my-event', { message: 'hello world' })
</script>✨ Features
| | Feature | |---|---| | 🆓 | Free forever — no hidden fees, no paywalls | | ⚡ | Real-time communication via WebSocket | | 🧩 | Channel-based pub/sub architecture | | 🔁 | Automatic reconnection with exponential backoff | | 🪶 | Lightweight (~5KB) and zero config | | 🔒 | Secure WSS connections | | 📦 | Works in Node.js and Browser |
📦 API Reference
new Emitra(appKey, options?)
Create a new client instance.
| Parameter | Type | Description |
|---|---|---|
| appKey | string | Required. Your App Key from evnt-flow.com |
| options.host | string | WebSocket server URL (default: wss://wss.evnt-flow.com) |
| options.debug | boolean | Enable debug console logs (default: false) |
const ef = new Emitra('YOUR_APP_KEY', { debug: true })ef.subscribe(channelName) → EmitraChannel
Subscribe to a channel. Returns a channel object.
const channel = ef.subscribe('chat-room')channel.on(eventName, callback) → this
Listen for a specific event on this channel.
channel.on('new-message', (data) => {
console.log(data)
})channel.trigger(eventName, data) → this
Send an event to the channel. All other subscribers will receive it.
channel.trigger('new-message', { text: 'Hi there!' })💡 The sender is excluded from the broadcast — only other clients receive the message.
channel.off(eventName) → this
Remove an event listener.
channel.off('new-message')ef.unsubscribe(channelName)
Unsubscribe from a specific channel.
ef.disconnect()
Disconnect from the server and clean up all subscriptions.
ef.onError(callback)
Listen for server-side errors (subscription errors, rate limit blocks, etc.)
ef.onError((err) => {
console.error('Emitra error:', err)
})ef.connected() → boolean
Check if the client is currently connected.
🧪 Testing
To test message delivery locally:
- Open two terminals (or two browser tabs)
- Both connect with the same App Key and subscribe to the same channel
- Send from one → receive in the other
The sender never receives their own messages — this is by design.
📁 Example
See the /example folder for a full interactive test client with UI.
🆓 Pricing
Emitra is free forever with generous limits:
- ✅ 50 messages/sec
- ✅ 500 peak connections
- ✅ 1 App Key
- ✅ Unlimited channels
Need more? Check out paid plans at evnt-flow.com.
📄 License
MIT © Emitra
