Prepare the Onions: Peel the onions, cut them in half, and slice them thinly. Separate the slices so they cook evenly.
Cook the Onions Slowly: Heat the butter and olive oil in a large skillet over medium-low heat. Add the sliced onions and salt. Cook for 25–30 minutes, stirring regularly, until the onions soften and turn deep golden brown.
Add Flavor: Stir in the sugar, balsamic vinegar, black pepper, and thyme. Cook for another 2–3 minutes until the vinegar is absorbed and the onions look glossy. Remove the skillet from the heat and let the onions cool slightly.
Prepare the Pastry: Preheat the oven to 400°F (200°C). Line a baking sheet with parchment paper. Unfold the thawed puff pastry and gently roll it into a rectangle, smoothing out any creases.
Shape the Tart Base: Transfer the pastry to the prepared baking sheet. Lightly score a border about ½ inch from the edges, being careful not to cut all the way through. Prick the center with a fork to help prevent excessive puffing.
Add the Filling: Sprinkle the Gruyère cheese evenly over the center of the pastry. Spread the caramelized onions on top, keeping the border clear. Finish with crumbled goat cheese.
Apply the Egg Wash: Whisk the egg and water together in a small bowl. Brush the exposed pastry border lightly with the egg wash to help it develop a golden finish.
Bake and Serve: Bake for 18–22 minutes, or until the pastry is puffed and golden brown and the cheese is melted. Let the tart rest for 5 minutes, garnish with extra thyme if desired, and slice before serving.