Preheat oven to 375°F (190°C). In a large non-stick skillet, heat oil over medium-high heat. Cook onion until tender, about 5 min. Stir in the spinach, remove from heat and keep covered until the spinach is wilted, about 2 min. Uncover and let cool completely. Stir in cooked pasta, reserved pasta water, tomato sauce, and ricotta. Transfer to an 8 x 8-in. (20 x 20 cm) baking dish. Nestle meatballs evenly in the pasta mixture. Top with mozzarella.
Bake covered with foil 20 min. Uncover and bake for an additional 10 min., or until cheese is melted and bubbling. To serve, garnish with fresh basil (if using).