---
title: "Discussion on \"Decoupling WebSockets from React Server Components\" | Hashnode"
description: "Discussion on \"Decoupling WebSockets from React Server Components\". Why router.refresh() kills your performance at scale, and the Snapshot + Delta pattern to fix it."
url: "https://hashnode.com/posts/decoupling-websockets-from-react-server-components/6aca6434edc78ca8dd27c97e"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Decoupling WebSockets from React Server Components](https://vishalraghav.hashnode.dev/decoupling-websockets-from-react-server-components?utm_source=hashnode&utm_medium=feed)

Why router.refresh() kills your performance at scale, and the Snapshot + Delta pattern to fix it.

Oct 10 · 8 min read · vishalraghav.hashnode.dev  
Updated Oct 26  
Read the article

-   [#software-development](https://hashnode.com/tag/software-development)
-   [#software-architecture](https://hashnode.com/tag/software-architecture)
-   [#reactjs](https://hashnode.com/tag/reactjs)
-   [#typescript](https://hashnode.com/tag/typescript)
-   [#understanding-concepts](https://hashnode.com/tag/understanding-concepts)
-   [#websockets](https://hashnode.com/tag/websockets)

## Written by

[Vishal Raghav](https://hashnode.com/@vishalraghav)

@vishalraghav

  
[View profile](https://hashnode.com/@vishalraghav)

Adapt to it

I am a learner and an explorer sharing my journey here on Hashnode. Please reach out if you like my work let's have a chat about it

## Responses 2

Markdown supported · ⌘↵ to post

[Yagya Goel](https://hashnode.com/@yagyagoel)

[Oct 10](https://hashnode.com/posts/decoupling-websockets-from-react-server-components/6aca6434edc78ca8dd27c97e/comment/6aca6765f9d95be939b7e0e8)

Awesome breakdown. RSCs definitely felt like a magic bullet at first, but separating out the real-time layer makes total sense. Great read

[Ahmet Özel](https://hashnode.com/@ahmetozel)

[Oct 11](https://hashnode.com/posts/decoupling-websockets-from-react-server-components/6aca6434edc78ca8dd27c97e/comment/6acb5a875c53a49145b03eae)

There is a lifecycle issue in the sample that would work against the snapshot-plus-delta design: getKey is an inline function in LiveActivityContainer, while the hook includes getKey in its effect dependencies. Each setData update rerenders the component, creates a new function and can close and reopen the socket.

I would give that key extractor a stable identity and add a test asserting that several incoming updates keep one connection open. Otherwise a healthy event stream can produce its own reconnect churn, even after removing every router.refresh call. That is separate from deduplicating the initial snapshot.
