Prep the oven and pan: Heat the oven to 375°F (190°C). Grease a 9x9-inch or similar baking dish with butter or spray.
Cook the spinach: If using fresh spinach, sauté it in a large skillet over medium heat with 1 tablespoon butter until wilted.
Transfer to a colander, cool slightly, then squeeze out as much liquid as possible. If using frozen spinach, thaw completely and squeeze dry. Excess moisture is the enemy of a firm bake.
Sauté aromatics: In the same skillet, add the remaining butter. Cook the onion for 3–4 minutes until soft, then add garlic for 30 seconds.
Remove from heat.
Whisk the base: In a large bowl, whisk cream cheese until smooth. Add heavy cream and whisk to a silky mixture. Beat in the eggs one at a time.
Stir in salt, pepper, a pinch of nutmeg, and red pepper flakes if using.
Add the cheeses: Fold in mozzarella and Parmesan until evenly combined.
Combine everything: Add the squeezed spinach, the onion-garlic mixture, and a bit of lemon zest if you like. Stir well so the spinach is coated and the cheese is evenly distributed.
Fill the dish: Spread the mixture into your prepared baking dish. Smooth the top and sprinkle with a little extra Parmesan for a golden crust.
Bake: Bake for 25–30 minutes, until the center is set and the top is lightly browned and bubbly.
The edges should be golden.
Rest and serve: Let the bake sit for 8–10 minutes to firm up. Slice into squares and serve warm.