Start by heating olive oil and butter in a large skillet over medium heat. Add the sliced onions and cook them slowly while stirring occasionally. The onions should become soft, golden, and deeply caramelized after about 25 minutes.
Add the balsamic vinegar, brown sugar, salt, pepper, and thyme once the onions turn golden brown. Cook for another few minutes until the mixture becomes rich and fragrant. Let the onions cool slightly before assembling the tarts.
Preheat your oven to 400°F (200°C) and line a baking tray with parchment paper. Roll out the puff pastry slightly so it bakes evenly and cut it into squares or rectangles.
Use a knife to lightly score a border around the edges without cutting through completely. This helps create a raised crust while baking and keeps the filling neatly inside.
Spread the caramelized onion mixture evenly inside the pastry borders. Sprinkle freshly grated Gruyere cheese generously over the onions for a rich and creamy topping.
Brush the pastry edges with beaten egg to help them bake golden and crisp. Make sure not to overload the pastry so it stays flaky and light during baking.
Place the tray in the preheated oven and bake for about 18–22 minutes. The pastry should puff up beautifully while the cheese melts and turns lightly golden.
Keep an eye on the tarts during the final few minutes because puff pastry can brown quickly. Once baked, remove them from the oven and allow them to cool slightly before serving.
Sprinkle extra thyme leaves or cracked black pepper over the warm tarts before serving. The fresh herbs make the tarts look elegant and add another layer of flavor.
I like serving these tarts warm because the cheese stays creamy and the pastry remains perfectly crisp. They also pair wonderfully with salads and soups.