What is Nostr?
frederik_diamond / FREDERIK DIAMOND
npub1nj0…2gqz
2025-02-23 10:58:41

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
This 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
Author Public Key
npub1nj0crmtetu84a7j43yegy358mp8u0e4ye7ndkhtd8dg0edll4mpqn52gqz