Next.js Discord

Discord Forum

Best practices / architecture for keeping information live with websockets

Unanswered
Singapura posted this in #help-forum
Open in Discord
SingapuraOP
I’m looking into transitioning a static frontend that uses RESTful service to get initial data + websockets to push new data updates to a Next.js site.

I’d like to replace all RESTful requests with server-side rendering, and then after the page is loaded, keep that data up to date with a separate websockets server (not Next).

Trying to understand best architecture for this. How to both pre-render data AND later make it client-side live-updated with websockets and local state.

1 Reply

You can pass the data from a server component to client components via props, then handle the data in client components (e.g. Storing it into a context, store, and SWR cache)