Next.js Discord

Discord Forum

Socket.io code firing twice

Unanswered
Siberian posted this in #help-forum
Open in Discord
SiberianOP
So I'm using socket.io with nextjs and express as the backend when I'm either trying to connect to my server or emit and event everything is firing twice I even tried adding if (typeof window !== 'undefine') but it's still firing twice how do I fix this?

https://pastebin.com/CcTXQuQ4

5 Replies

Are you using strictmode in development? https://react.dev/reference/react/StrictMode
SiberianOP
I don't think I'm using strictmode I'm just running it out of box
Strict mode IIRC is the default behaviour when developing
SiberianOP
I'll take a look and tell you then
I'm outside so it'll take some time