3

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?

3
  • 1
    When I google "nextjs socket.io" I get a bunch of promising results; have you looked into these yet? Commented Dec 23, 2020 at 9:20
  • Yes. But none of them are satisfactory for me!! Commented Jan 6, 2021 at 9:09
  • You need to add to your question the specific code you've tried, and a description of why it fails, including relevant error messages. Commented Jan 6, 2021 at 10:44

2 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

Comments

2

Yes. It is possible to use socket.io on the same server as next.js.

I have created a github repo implementing this thing. It is a very simple and working starter template for Next.js and socket.io.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.