Buying a stock during its initial public offering (IPO) can be risky. Yet it can also make you rich.

Starbucks (SBUX -1.02%) has generated staggering returns for its shareholders since its IPO in 1992. As the coffee titan has come to dominate the cafe industry in the U.S. and many other areas of the world, it's changed the lives of many of its investors along the way. 

Milk froth and coffee in the shape of a smiley face inside a coffee mug.

Starbucks' shareholders have a lot to be happy about. Image source: Getty Images.

During a trip to Italy in 1983, Howard Shultz fell in love with the ambiance of the coffee bars he visited and had a vision for what he wanted to build in America. A few years later, Shultz would raise the funds he needed to purchase a little coffee shop company named Starbucks from its founders. He then set off to turn his vision into reality. 

Starbucks's growth has been stunning. Its stock made its debut on the public markets on June 26, 1992. It had 165 stores at the time. Today, Starbucks has nearly 33,000 stores worldwide. 

If you had invested $10,000 in Starbucks at its IPO price of $17, you would have purchased roughly 588 shares. Since then, Starbucks has split its stock 2-for-1 six times. Your 588 shares would now be 37,632 shares. At Starbucks' current stock price near $106, your $10,000 investment would be worth nearly $4 million today.

Better still, you'd now be collecting more than $67,000 in dividends every year, based on Starbucks' current quarterly dividend of $0.45 per share. 

Not bad, for an investment in a little cafe company.