Healthcare can be a major expense, especially during retirement. So it's important to set money aside for it consistently.

That's where health savings accounts (HSAs) come in. With an HSA, you can contribute money for near-term or far-off healthcare expenses. Unlike flexible spending accounts, which require you to spend down your plan balance year after year, HSA funds don't come with an expiration date. You can put money into an HSA in your 20s and carry that money all the way into retirement -- which is something it definitely pays to do, since chances are, medical bills will be more of a burden during your senior years than they are during your working years.

But HSAs offer one important feature that many savers may not be taking advantage of. And that's a big mistake.

A person at a laptop.

Image source: Getty Images.

Are you making the most of your HSA?

The money you have in your HSA that you aren't using immediately doesn't have to just sit in cash. You can invest that money and grow it into a larger sum, the way you can (and should) invest the money you have sitting in your 401(k) plan or IRA.

But in a recent report by Fidelity, only 21% of HSA enrollees are actually investing their money. And while Fidelity does report that HSA balances are up, those who aren't investing the cash in their accounts are losing out on a big wealth-building opportunity.

Not only do HSAs give savers the chance to grow their money, but they can do so in a tax-advantaged manner. That's because investment gains in an HSA can be enjoyed tax-free, as can withdrawals, provided they're used to cover qualified medical expenses. In this regard, they're similar to Roth IRAs and 401(k)s.

Furthermore, HSAs can actually double as a retirement savings plan for those who are able to carry their money that far into the future. Normally, HSA withdrawals for non-medical purposes are taxed and penalized. But once you're age 65, those penalties no longer apply. So if you have funds in an HSA by age 65 that you don't need for healthcare bills, you can withdraw your money for any purpose. The only consequence is that you'll be taxed on that distribution, the same way you'd pay taxes for withdrawing funds from a traditional 401(k) or IRA.

Don't let your saving stagnate

The cost of healthcare has risen steadily over time, and that extends to Medicare-specific expenses as well. Unfortunately, HSAs aren't open to everyone. That's because eligibility to participate in one hinges on being enrolled in a high-deductible health insurance plan, which not everybody has.

But if you are eligible to participate in an HSA, it pays to max out your annual contributions if possible, invest your money, and carry it with you into retirement, when your medical costs might rise. Having a dedicated source of healthcare funds could help you avoid a world of financial stress once your senior years roll around and your medical bills start increasing.