Follow the steps in order for the best result.
Begin by preheating your oven to 350°F (175°C).
Select a medium-sized pot that is suitable for both stovetop and oven use. Place the pot over medium heat and melt the butter or add the olive oil.
Introduce the chopped onions to the pot and sauté for approximately 3 to 5 minutes, stirring occasionally, until they become soft and translucent.
Incorporate the long-grain white rice into the pot, stirring continuously to ensure that each grain is thoroughly coated with the butter or olive oil.
Pour in the chicken or vegetable stock, and season with salt and pepper according to your taste preferences.
Bring the mixture to a boil.
Cover the pot tightly with a lid and transfer it to the preheated oven. Bake for about 20 to 25 minutes, or until the rice is cooked through and all of the stock has been absorbed.
Once baking is complete, remove the pot from the oven and allow it to stand, covered, for 5 minutes before serving. This will allow the rice to finish steaming and achieve the perfect texture.