#Quick question, does anyone maybe have
1 messages · Page 1 of 1 (latest)
Hello
so it depends on more specifics of what you wish to achieve.
nextjs mostly helps to generate stateless functions for a stateless server architecture:
you would implament real-time features on a client side
Depending on how dynamic and responsive you wish page section or a component to be.
All I pretty much need is to be able to emit some stuff from the Client to the server with socket.io
Why not a server function?
What do you mean?
Why not
async function postMessage(
props: PostMessageProps
) {
"use server";
const sokect = new OurSocket(our_credentials);
const result = putToDBMessageMethod(props.message);
if (result.ok)
{
socket.emit(props.channel, props.message);
}
}
async function MessagesList() {
....get mesages here
return (...mesages)
}
function OurPage() {
return (
<MessagesComponent
postMessageMethod={postMessage}
>
<Suspense>
<MessagesList/>
</Suspense>
</MessagesComponent>
);
}
Well I guess I can do it like that, but I also need a way to have the socket running. That's the issue I'm having currently, I don't actually know how to get socket.io/websockets setup to do real time stuff
"use client";
function OurDynamicItems(... initial items) {
const data = useChannelMessages(..some channel); // statefull hook
return (
<OurDataTranspiler
data={data}
/>
);
}
You would need to have a state that can be affected by a socket.
aha the thing is, next and vercel does not directly provide message brockering
You can start learning message brockering with
https://pusher.com/
else you can make web socket service separate
I dont know if revalidateTag would trigger users to receive new updates on a page partials
It's getting a bit complicated for me right now, I think I'll do a bit more research and see what I can do. I appreciate your help
good luck with designs, if you wish please isolate small tests, to learn from experiments. if you learn more about it, feel free to let me know