Prepare the onions. Heat olive oil and butter in a large sauté pan over medium-low heat. Add the sliced onions and a pinch of salt. Cook slowly for 30-35 minutes, stirring occasionally, until deeply golden and caramelized. Be patient—rushing this step will give you sautéed onions, not caramelized ones.
Finish the caramelization. Add balsamic vinegar and brown sugar to the pan, stirring to incorporate. Cook for another 2-3 minutes until the liquid is absorbed. Stir in thyme leaves, then remove from heat and let cool completely.
Preheat your oven to 375°F (190°C) and lightly grease your tart pans or muffin tin.
Prepare the pastry. Roll out the puff pastry slightly on a lightly floured surface. Cut into rounds slightly larger than your tart pans or muffin cups. Press gently into the pans, trimming any excess.
Mix the filling. In a small bowl, combine 3/4 of the goat cheese with heavy cream until smooth. Season with salt and pepper to taste.
Assemble the tarts. Spread a thin layer of the goat cheese mixture on the bottom of each pastry shell. Top with a generous spoonful of caramelized onions. Sprinkle the remaining goat cheese on top.
Brush the exposed pastry edges with beaten egg for a golden finish.
Bake for 15-20 minutes until the pastry is puffed and golden and the filling is hot. If using nuts, sprinkle them over the tarts during the last 5 minutes of baking.
Let the tarts rest for 5 minutes before serving warm or at room temperature.