The sugar most likely starts the bubbles forming, and compounds in the coffee help them last as foam.

Sugar crystals have tiny crevices and trapped air pockets where bubbles can begin to grow. These are called nucleation sites. Heating reduces how much dissolved gas the liquid can hold, so adding sugar can help that gas escape as many small bubbles. If the coffee is near or above its boiling point, the sugar can also trigger a brief burst of steam bubbles. [Physicist Lou Bloomfield explains both mechanisms.](https://howeverythingworks.org/1997/06/18/question-1183/)

Microwave heating can make this effect more noticeable. It heats the liquid directly, without the hot vessel surface that usually encourages bubbles to form on a stovetop. In a smooth glass, bubble formation can be delayed until you add the sugar. How much this explains the difference you saw depends on the temperatures and how much you stirred or poured the coffee with each method. [UNSW explains microwave heating and nucleation.](https://www.animations.physics.unsw.edu.au/jw/superheating.htm)

Coffee contains natural compounds that help keep bubble walls from breaking, including protein-related substances, melanoidins and polysaccharides. That lets the bubbles persist as foam. Their longevity suggests they contain air or other gases that do not condense as the coffee cools; bubbles made entirely of steam would disappear. [Research on coffee’s foaming compounds](https://pubmed.ncbi.nlm.nih.gov/15537326/)

The foam alone does not prove the coffee was superheated. Small, persistent bubbles are consistent with dissolved gas escaping. Sudden, vigorous boiling when you add sugar would be stronger evidence of superheating.