Search code examples
javascriptnode.jsexpresssocketsnext.js

How to implement Socket.io with next.js without separate node server


I want to build a chat system with Next.js. I am not sure how I have to setup the socket server.

I want this to implement Next server not with a separate server. Should I have to make a server.js file in root and run a server?


Solution

  • You will need to create custom server however, then you can't deploy to vercel, and you got yourself a regular nodejs application. You could use cloud providers to handle sockets for you, or as you said, you could split your application to a regular next.js app and deploy your socket application separately.