Your friends will need to have purchased SDV from the same source, so everyone needs to be using the same one of these:
Switch
PS
XBox
PC/Mac/Linux using GOG Galaxy
PC/Mac/Linux using Steam
And yes, you connect to them using a player code or username. There's no online play for mobile devices (iOS, Android) unfortunately.
Here's the Multiplayer info:
Multiplayer is an optional game mode in which 1–8 players can join the same world through split-screen, over LAN, or by IP address. Multiplayer is available on the PC (Linux/Mac/Windows) and console (PS4/Switch/Xbox One) versions but not on PS Vita. Multiplayer is available on mobile...
stardewvalleywiki.com