Menu

chanx-js: typed WebSocket hooks for React, generated from your chanx server's AsyncAPI

Reddit r/reactjs·u/huygl99·12 days ago
#jbNQId8V
#chat#chanx#room#payload#article
Reading 0:00
15s threshold

Hi all, I want to share a WebSocket library I built, chanx-js. It makes the messages on both ends of a socket typed, keeps the frontend in sync with what the server really sends, and comes with React hooks.

Every realtime feature I built in React ended up the same way. lastMessage was any , so I wrote the message types by hand and found out the backend had changed them only when something broke in production. On top of that I kept rewriting the same reconnect logic and the same switch over message types in every project.

How it works, in three steps: `

The server declares its messages and handlers.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.