I'm trying to implement this idea but I don't know what's the best way to do it.
There should be a button to queue up for a game, and there should be game rooms with 3 players in each.
Since your question is rather vague, I will give you a general workflow.
Sample Code for joining a room after connection established.
// io is exposed as a global variable in the client once you import the library.
// Join an existing room on connection established
io.on('connection', function(socket){
socket.join('some room');
});
// Establish a websocket connection
var socket = io();