socket.on('connect', () => { // ... }); // note: you should register event handlers outside of connect, // so they are not registered again on reconnection socket.on('myevent', () => { // ... });
References
https://socket.io/docs/client-api/#Event-%E2%80%98connect%E2%80%99