Heat olive oil in a large skillet or frying pan over medium heat. Add the chopped onion and sauté until softened and translucent, about 5 minutes.
Add minced garlic and jalapeño pepper (if using) to the skillet. Sauté for an additional 3-4 minutes until the pepper starts to soften.
Add the chopped spinach to the skillet. Cook until they wilt down, about 3-5 minutes.
Season with salt and pepper. Mix well to combine all the flavors.
Create small wells in the greens mixture and carefully crack the eggs into each well. Cover the skillet with a lid and let the eggs cook to your desired doneness. For runny yolks, cook for about 4-5 minutes. If you prefer firmer yolks, cook for a few minutes longer.
Once the eggs are cooked, remove the skillet from heat. Sprinkle crumbled feta cheese and fresh herbs over the shakshuka if desired.
Serve the shakshuka directly from the skillet, accompanied by warm crusty bread for dipping.