0.1.2 • Published 7 months ago

@simply-justin/react-ws v0.1.2

Weekly downloads
-
License
ISC
Repository
github
Last release
7 months ago

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:

  1. Fork the repository.
  2. Run npm install
  3. 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.

0.1.2

7 months ago

0.1.1

7 months ago

0.1.0

7 months ago

0.0.2

7 months ago

0.0.1

7 months ago