Preheat the oven to 350°F and grease a baking dish with butter.
In a saucepan, sauté onions and garlic in melted butter until fragrant.
Add sliced potatoes to the pan and cook until slightly softened.
In a bowl, combine cream, shredded cheese, salt, and pepper.
Layer potatoes in the baking dish and pour cheese mixture over each layer.
Cover with foil and bake for 30 minutes, then uncover and bake for an additional 20 minutes until golden.
Let rest before serving. For extra crispiness, broil for a few minutes before serving.
