#Quick question, does anyone maybe have

1 messages · Page 1 of 1 (latest)

brave oak
#

Hi

whole garnet
#

Hello

brave oak
#

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.

whole garnet
#

All I pretty much need is to be able to emit some stuff from the Client to the server with socket.io

brave oak
#

Why not a server function?

whole garnet
brave oak
#

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>
  );
}
whole garnet
brave oak
#
"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

#

else you can make web socket service separate

#

I dont know if revalidateTag would trigger users to receive new updates on a page partials

whole garnet
#

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

brave oak
#

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