frederik_diamond on Nostr: Turns out I had not setup SocketIO correctly, that’s why the notifications ...
Turns out I had not setup SocketIO correctly, that’s why the notifications weren’t received.
Or more specifically, I did receive them eventually, but that wasn’t due to SocketIO, it was just NextJS doing a component refresh, and therefore fetching the notification history from the database using the API route and not SocketIO.
Now, the unread notification counter is updating in real-time.
Next step is to show the notifications in real-time. #dev
Or more specifically, I did receive them eventually, but that wasn’t due to SocketIO, it was just NextJS doing a component refresh, and therefore fetching the notification history from the database using the API route and not SocketIO.
Now, the unread notification counter is updating in real-time.
Next step is to show the notifications in real-time. #dev
quoting note1kv7…cacvThis afternoon I’ve been working on implementing the notification system in my portfolio project.
I settled on using Socket.IO running in an Express server.
I had to do some restructuring as I did not want to implement a custom server running Socket.IO directly inside of NextJS. Because then I lose Turbopack (I think if I understood the docs correctly).
So I made two directories in the project:
- `client/` for the NextJS project
- `server/` for the Express and Socket.IO
It’s up and running. One of the notifications is when a user publishes a new post. That’s the only one working currently, but the plan is to implement more notification types.
It takes a little while before the notification is received. Not sure why.
I did a project in last semester of my SE degree where we used SignalR connected to Blazor, and the notifications were received instantly. I want this NextJS and Socket.IO project to be the same. I’ll have to tinker with it tomorrow. Also need to make the notification UI nicer.
#dev #NextJS #SocketIO #NodeJS #portfolio