#sockets in app directory

17 messages · Page 1 of 1 (latest)

hexed escarp
#

how can i manage to use sockets with app directory

verbal eagleBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

hexed escarp
flat musk
#

Websocket? Unfortunately, Next.js is built for serverless, which means you can’t run a websocket server without using a custom node.js server. Custom server isn’t allowed by platforms like Vercel, also not a recommended way.
Generally, we will use 3rd party services, such as Ably Realtime. They work great for serverless environments. Websocket needs an actual persistent server, and Next.js doesn’t come with that by default.

scenic gyro
# hexed escarp

if you're hosting this nextjs app in a serverful environment then yes you can keep it in that file else you will need custom backend if you wanna host on vercel

hexed escarp
#

is Ably Realtime free?

flat musk
#

Yep

hexed escarp
#

thanks

#

so i can build express server and connect it to nextjs app

flat musk
#

Correct

#

But considering the cost to host server, maybe simply using a service is better for small projects

hexed escarp
#

i need it for small chat application

flat musk
#

I built Shark chat, it’s a simple chat app, and it’s using Ably

scenic gyro
flat musk
#

The price of Ably Realtime seems to be cheaper, you can take a look to their pricing

hexed escarp
#

i dont know what is required for the task actually i have to ask and then i will see which service or platform i will use