A FEW years ago, tough and tasteless baked goods were just one of the unpleasant things you had to put up with if you had a gluten sensitivity.

Flash forward less than a decade, and it’s a completely different scene. Gluten-free cookies, pies and cakes are starting to rival their traditional counterparts.

At Babycakes, a vegan and gluten-free bakery with branches in Manhattan and Los Angeles, Erin McKenna’s cake doughnuts are so feather-light and deeply flavored that no one would guess they’re wheat-free. And a whole-grain muffin recipe by Shauna James Ahern produces muffins so ethereal, fluffy and tender they seem like pastries from another planet — a sweet one, without gravity — and better than most other whole-grain muffins made with whole-wheat flour.

Gluten-free baked goods have become tastier as demand for them has risen. More Americans — about 6 percent of the population, according to the Center for Celiac Research at the University of Maryland — have found that gluten, in wheat, barley and rye, causes health problems. What had been a niche market has become mainstream.