She thought about moving in with her sister in Florida, but knew it would put a strain on their relationship. A native New Yorker, Ms. Felstein has lived in the same apartment for almost 40 years and had no desire to move.

So she did what many others do to keep costs down in an expensive city: She found a roommate.

Instead of placing an ad online, however, Ms. Felstein turned to the New York Foundation for Senior Citizens, a Manhattan-based nonprofit. The group has been operating a home-sharing service since 1981, matching people who have space in their homes with those in need of affordable housing. It is one of a number of similar programs that have emerged across the country as the population of older Americans grows, as a way to help people stay in their homes.

The concept of pairing older people with younger ones, particularly those who are not family members, is not a new one: It was popularized by Maggie Kuhn, an elder-rights activist who opened up her Philadelphia home to others for more than 20 years before she died in 1995. Today’s home sharing, however, is as likely to be between those of the same age as it is to be intergenerational. The crucial thing is that it involves two or more people sharing an apartment or a house to their mutual benefit. And finances often play a big role.

For those who are still working age, it’s getting harder to pay the rent: According to a StreetEasy survey, rents in the city rose twice as fast as wages between 2010 and 2017. The lowest rents (those up to $2,300) rose 4.9 percent annually since 2010, which means someone who paid $1,500 a month in 2010 likely paid nearly $600 more for the same place in 2017.

For baby boomers entering retirement, financial security is also increasingly hard to come by. Many Americans may think they have plenty of savings, but about half have not saved enough to maintain their pre-retirement living standards, according to a recent estimate by the Center for Retirement Research at Boston College. The rising cost of health care, increased life expectancy and lower interest rates only exacerbate the situation. In addition, a Fannie Mae survey found that baby boomers are more likely to be carrying mortgage debt into their retirement years than previous generations were.