0.1.2 • Published 7 months ago
@simply-justin/react-ws v0.1.2
Table of Contents
☑️ Features
- 100% Type-Safe: Ensure all communication—incoming and outgoing—is fully typed.
- Minimal Footprint: No external dependencies. Just pure TypeScript.
- Zero Build Complexity: No additional build tools, CLI configurations, or code generation needed. Works seamlessly out of the box.
🛠️ Installation
npm i @simply-justin/react-ws
🚀 Usage
// layout.ts
import { WebsocketClientProvider } from '@simply-justin/react-ws'
export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode
}>) {
return (
<html>
<body>
<WebsocketClientProvider url='wss://{WEBSOCKET_URL}'>
{children}
</WebsocketClientProvider>
</body>
</html>
)
}
'use-client'
import { useWebsocketClient } from '@simply-justin/react-ws'
export default function ExamplePage() {
const websocketClient = useWebsocketClient(() => { console.log("I'm getting called on every incomming message.") })
}
⚙️ API Reference
WebsocketClientProvider
useWebsocketClient
🤝 Contributing
Contributions are welcome! To get started:
- Fork the repository.
- Run
npm install
- Implement your changes or additions.
For major changes, please open an issue first to discuss your proposed modifications and make sure to update the tests and documentation as needed.
!NOTE Don't forget to run the tests before submitting a pull request.
📝 License
This project is licensed under the MIT License.