Using SharedWorkers to persist websocket connection

I’m starting to work on optimizing my websocket connections.

Currently all pages on my site stand alone, each one establishes a new connection on page load using a session token saved in sessionStorage.

Connecting onload works fine but adds a little delay during the setup and I’m sure its not going to work very well at scale.

I don’t really want to change to a SPA because I prefer the micro frontend approach, so I’m looking at my options, ShareWorkers seems to be a popular approach.

Has anyone used resClient in a sharedworker, if so do you have any examples or advice?

1 Like