Melt a big piece of butter in a pan on medium heat. Add the onion and stir until the onion is coated in butter. Keep cooking the onions on low heat until they’ve caramelised (about 30 min). No need to add sugar!
Season the onion with salt and pepper and add some fresh thyme
Preheat the oven to 200°C. Roll out the puff pastry and make some markings with a fork
Add the onion on top of the puff pastry and top it off with some fresh cheese. Add some more thyme
Whisk an egg and coat the sides of the puff pastry
Cook everything for 20-30 min or until everything is nice and brown