Season ground beef with salt and pepper; divide into 4 equal-sized balls. Shape each ball as close as possible to the shape of the bread.
Make an indentation in the centre of each patty with your thumb to help keep them flat while cooking
Melt butter in a skillet over medium heat. Add onion; cook and stire until soft and translucent (5-7 minutes)
Transfer onions to a bowl and set aside. Turn the heat to medium-high. Place beef patties into the same skillet and cook until desired doneness (approx. 3-5 minutes per side).Ensure the internal tempurature is 170°F
Spread 1 teaspoon of mayonnaise on one side of each slice of bread.
Place 4 slices of bread mayonnaise-side down in the skillet. Top each with 1 slice of cheese, 1 beef patty, 1/4 of the onions, a second slice of cheese, and another slice of bread, mayonnaise-side up.
Cook bread until golden brown and cheese has started to melt (approx. 3-4 minutes). Flip each sandwich over and cook an additional 3-4 minutes.