apteryxxyz / next-ws

Add support for WebSockets in Next.js app directory.
https://npmjs.com/next-ws
131 stars 9 forks source link

Implement `next-ws` with other `Node.js` Framework #17

Closed asmdhabibullah closed 5 months ago

asmdhabibullah commented 5 months ago

Here is the idea

  1. Developers can have a separate server-side application using different frameworks ("Express, Meteor, Angular, etc.").
  2. next-ws can be installed in the backend application as well.
  3. next-ws can handle cors or other header-related objects.
  4. next-ws can send and receive followed by the socket protocol in both directions.

Today I suggest a developer use the "socket.io" package because the developer wants to use a separate backend and frontend next-ws package

I think this feature is necessary for developers.

apteryxxyz commented 5 months ago

I'm not entirely sure what you are asking. Next WS's purpose is to patch Next.js to add a WebSocket server with simple route handlers.

a separate server-side application using different frameworks ("Express, Meteor, Angular, etc.").

If you have a separate app for your backend, then you do not need Next WS, you can just add a WebSocket server (socket.io if you want) to your backend app.

The StackOverflow question you linked appears to someone trying to use WebSockets server on Vercel. They are trying to use Next WS even though they have a separate server.

Next WS should not be used if you only need its client-side functionality.

asmdhabibullah commented 5 months ago

I understand, Next WS package is only for Next.js environment but the developer can have a separate server.

I mean to say if someone wants to use Next WS in the frontend then how they can handle backend, do you have any alternative solution or suggestion for this feature?

Ok, If you are not willing to add this feature then no problem. Let me close the issue.

apteryxxyz commented 5 months ago

I mean to say if someone wants to use Next WS in the frontend

If someone is trying to use Next WS in the frontend then they don't know the purpose of Next WS. Next WS has nothing to do with the frontend, Next WS's purpose is to expose a WebSocket server to vanilla Next.js without the need for a separate server or custom server. If someone has a separate server, then they do not need Next WS, because they can just implement the WebSocket server in their separate server.

IMPORTANT: You do not need Next WS, if you have a separate backend server.

asmdhabibullah commented 5 months ago

Ok, good. then let's close :)