Preheat the oven to 350 degrees Fahrenheit.
Cook the spaghetti according to package directions in a large pot of boiling, salted water, but cut the cooking time by 2 minutes. Reserve ½ cup of the water in which the pasta was cooked.
In a 12-inch cast iron skillet over medium heat, sauté the onions and olive oil. Add in the garlic and continue sautéing until onions are tender.
Add the marinara sauce. Cook for about 10 minutes, until the sauce has thickened.
With a large slotted spoon, add the cooked spaghetti. Stir until the pasta is evenly coated in the marinara sauce. If the sauce is too thick, add up to ½ cup of the pasta water to the pan.
Add the cooked meatballs and stir to coat in sauce.
Top with the grated mozzarella and the Parmesan.
Bake for 20 to 25 minutes, until the dish is hot and bubbly and the cheese is melted. Garnish with fresh basil.