Base recipe for 1 liter of root beer: half a tablespoon of root beer extract (I use Zatarain’s) and half a cup of sugar (raw/turbinado sugar is especially nice).
For typical root beer, make half a cup of simple syrup by combining the sugar with half a cup of water and heating until the sugar is dissolved, then add it and the extract to 750mL of sparkling water.
However, for home-brewed root beer, which has a more complex flavor (and a slight amount of alcohol), combine the sugar, extract, 1 liter of water, and 1 teaspoon of yeast (baker’s yeast is fine, champagne yeast is better) into a clean 1-liter plastic bottle. Squeeze the air out and cap, and allow to sit at room temperature until the bottle has expanded and become firm to the touch, and then move it into your refrigerator to chill. This process depends on the temperature, and can be sped up or better controlled using a sous vide circulator set to around 90°F which should make the fermentation take only a few hours.
NOTE: Be absolutely careful not to let this stay out past the time it has gotten firm, or else you run the risk of the bottle exploding and making a mess! And, for that matter, only use a flexible plastic bottle (I use leftover seltzer bottles) and not a firm bottle like a SodaStream or, worse yet, a glass bottle, as those will be very difficult to use safely and are very likely to explode on you.
Anyway, the nice thing about brewed rootbeer is that the flavor will continue to develop over time in the refrigerator, and it won’t easily go flat, as the yeast will continue to ferment and carbonate it even while cold. (This will also increase the alcohol content over time.)
I highly recommend storing the bottle upright, if possible, as the yeast will form a sediment on the bottom of the bottle and this doesn’t have a very good taste or texture. Keeping it upright makes it easier to pour off the root beer without ending up with the yeast slurry.