Before you start baking rice, check the packaging for the rice-water ratio for the particular variety, so there is no danger of boiling it or leaving it too raw. Usually it is 1:3.
Whether you fry the onion briefly, beforehand or pour it directly into your pan is your choice. It is important to add enough fat, because rice loves it. Baking rice takes about 30-40 minutes, depending again on the variety of rice, your oven, etc.
It is advisable to turn off the oven when you see the rice grains appearing above the liquid (water or broth) and leave the dish in the warm oven for at least another 20 minutes.