On the surface, you'd think today's economy was pretty strong. Unemployment levels are low and inflation is finally cooling.

In spite of that, data from Allianz reveals that Americans are largely pessimistic about the state of the U.S. economy. Not only have 61% of Americans taken a financial hit over the past year due to rising interest rates, but 64% are worried that a major economic recession is due to strike any minute now.

Clearly, the latter is a scary thought in general. But it can be especially daunting for those who are on the cusp of retiring. So if you're worried about a recession and have plans to retire within the next couple of years, there's one key move you need to make.

A person at a laptop.

Image source: Getty Images.

Protect your plans with ample cash

Ideally, the money you have socked away in your IRA or 401(k) plan isn't just sitting all in cash. It's important to continuously invest your money so that it grows into a larger sum not just in the years leading up to retirement, but also during retirement.

That said, it's always a good idea to make sure you have at least a year's worth of expenses on hand as retirement nears. And in light of the potential for a near-term recession, if you intend to retire within the next couple of years, you may want to keep two years' worth of expenses on hand in cash. That way, if the economy takes a notable turn for the worse and that affects your portfolio, you won't necessarily be looking at losses. You may have the option to leave your investments alone and fall back on the cash you've reserved.

Along these lines, keeping ample cash on hand could spell the difference between having to postpone retirement or stick to your plans. If you've worked hard all your life and were anticipating a specific retirement date, the last thing you'd want is to be forced to keep plugging away at a job for fear of taking losses in your retirement portfolio.

How worried about a recession should people be?

Without a crystal ball, it's impossible to know whether a recession will hit in the near term, how long it might last, and how bad it might get. That's why it's generally a good idea to keep some amount of cash on hand for emergencies, or to cover living expenses in the event of getting laid off.

The advice to sock away enough cash to cover one to two years of living expenses doesn't necessarily apply to the general population the same way it applies to near-retirees. However, at a minimum, you should aim to have enough cash available to pay for three full months of essential bills. Doing so could not only get you through a period of joblessness should you land in that boat, but it might also spell the difference between having to cash out investments at a loss versus being able to ride out an economic downturn.