Preheat the oven: Set to 350°F (175°C). Lightly grease a 9x13-inch baking dish with butter or oil.
Sauté aromatics: In a skillet over medium heat, warm the butter or olive oil.
Add diced onion and cook 3–4 minutes until translucent. Stir in the garlic and cook 30 seconds until fragrant.
Cook the spinach: Add chopped fresh spinach to the skillet and cook 2–3 minutes until wilted. If using frozen, make sure it’s thawed and squeezed dry, then warm it through in the skillet to drive off extra moisture.
Season lightly with a pinch of salt.
Whisk the egg mixture: In a large bowl, whisk eggs, heavy cream, salt, pepper, nutmeg, and red pepper flakes. Whisk until smooth and slightly frothy.
Add the cheeses: Stir in the mozzarella and cheddar, reserving a small handful for sprinkling on top. Fold in the spinach mixture.
Assemble: Pour the mixture into the prepared baking dish.
Smooth the top, sprinkle with the reserved cheese and the Parmesan if using.
Bake: Place on the center rack and bake 22–28 minutes, until the edges are set and the center has a slight jiggle but is not liquid. A knife inserted near the center should come out mostly clean.
Rest and slice: Let cool 5–10 minutes to finish setting. Slice into 9–12 squares and serve warm.