Today I Learned

A Hashrocket project

Ready to join Hashrocket? Find Openings here and apply today.

Expo Go over VS Code Live Share shared servers

VS Code Live Share is a pretty sweet way to remote pair. It supports Shared Servers, a fancy way to forward ports without exchanging ssh keys. Unlike ssh port forwarding, however, there isn’t a way for the joiner to choose which of their local ports will be used. The port selection is random.

That doesn’t cut it with Expo Go (and maybe vanilla react-native?) which demands the port be the same for the server and the client. So I looked for a way to forward one port on my local machine, the random one chosen by Live Share, to another port on my machine - the expo default of 19000.

Thanks to socat that was easy:

 socat tcp-listen:19000,reuseaddr,fork tcp:localhost:<random liveshare port>

I opened exp://localhost:19000 in Expo Go in the simulator. 🤘 Sweet.

Looking for help? At Hashrocket, our JavaScript experts launch scalable, performant apps on the Web, Android and iOS. Contact us and find out how we can help you.