Preheat your oven to 400°F (200°C). Line two baking sheets with parchment paper.
Heat olive oil in a skillet over medium heat. Add onion and cook until soft, about 3 minutes.
Add spinach to the skillet. Cook until wilted, about 5 minutes. Squeeze out as much excess liquid from the spinach mixture as possible using a clean towel or paper towels. This step is key for flaky pastry.
Transfer the spinach mixture to a bowl. Add salt, pepper, nutmeg, cream cheese, and feta cheese. Mix well until combined.
Unfold the thawed puff pastry sheets on a lightly floured surface. Cut each sheet into 6 equal squares.
Place about 2 tablespoons of the filling onto one half of each pastry square, leaving a 1/2-inch border.
Fold the other half of the pastry over the filling to form a triangle or rectangle. Press the edges firmly together with a fork to seal. Crimp the edges to create a tight seal.
Place the sealed pastries on the prepared baking sheets. Brush the tops evenly with the beaten egg wash. Sprinkle with sesame seeds if using.
Bake for 18 to 20 minutes, or until the pastries are puffed and golden brown.
Let cool slightly on the baking sheet before serving.
Notes
For the flakiest results, ensure your puff pastry is very cold when you start cutting and folding.
Do not overfill the pastries; too much filling prevents the layers from rising properly.
If you do not have feta, substitute with ricotta or goat cheese for a different flavor profile.