T
TanStack•16mo ago
modern-teal

How to prevent usage of client only api's on the server? (tanstack router)

Hey 🙂 I have a hook, which is initializing a new RTCPeerConnection(). This errors on the server (obviously). How do I best handle this case? I could try to return early, if process.browser is not defined. But this will lead me to conditional hook calling.
1 Reply
genetic-orange
genetic-orange•16mo ago
if the hook initializes the connection in an effect or in useSyncExternalStore, it shouldn't run on the server

Did you find this page helpful?