elsolya-pusher
v1.1.0
Published
Framework-agnostic Pusher wrapper
Readme
elsolya-pusher
A framework-agnostic wrapper around Pusher JS that works with any framework (React, Vue, Angular, Svelte, Next.js, Nuxt, Node.js, Vanilla JS).
✨ Features
- ✅ Framework-agnostic (no hooks, no composables)
- ✅ Works in Browser & SSR environments
- ✅ Simple and clean API
- ✅ Written in TypeScript
- ✅ Tree-shaking friendly
- ✅ Production-ready
📦 Installation
npm install elsolya-pusheror
yarn add elsolya-pusher🚀 Usage
Initialize Pusher
import { createPusher } from "elsolya-pusher";
const pusher = createPusher({
key: "PUSHER_KEY",
cluster: "eu",
});📌 Framework Examples
React
useEffect(() => {
const pusher = createPusher(config);
const channel = pusher.subscribe("chat");
return () => {
pusher.unsubscribe("chat");
};
}, []);Vue / Nuxt
const pusher = createPusher(config);
pusher.subscribe("chat");Angular
@Injectable()
export class RealtimeService {
pusher = createPusher(config);
}Vanilla JS
<script type="module">
import { createPusher } from "elsolya-pusher";
const pusher = createPusher(config);
</script>⚙️ Configuration
interface PusherConfig {
key: string;
cluster: string;
authEndpoint?: string;
}🧠 Notes
- This library does NOT depend on any frontend framework.
- You control subscriptions and bindings manually.
- Safe to use in SSR frameworks (Next.js / Nuxt).
📄 License
MIT © Ahmed Elsolya
