Using Typescript, what's the recommended way to extend socket.handshake.auth with the custom properties set on frontend? #4706
Unanswered
decipher-cs
asked this question in
Q&A
Replies: 1 comment
-
I went with this: declare module 'socket.io' {
interface Socket {
username?: string
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am sending a username from my frontend
socket.auth = { username: 'example_name' }
which I am receiving on the backend like this
But this will require me to typecaste socket in multiple places. This makes the code smelly imo.
Now what I am asking is, is this the right and expected way to set properties on the socket or is there a better way that I missed while skimming the docs?
Beta Was this translation helpful? Give feedback.
All reactions