This is incredibly complicated and I’m not really going to answer your question directly. There are a variety of design and urban planning techniques to help cities be more dense while being more livable. Form Based Code, Smart Growth, sustainable planning, etc., are very common, easily replicable, and very flexible solutions to this.
The problem with these solutions are that people are not staying in one place for very long. This trend of people moving to cities will slow a bit, and cities can adapt and absorb the influxes.
The real question, to my mind, is how to make them stay? These new people rarely participate in local government. They rarely stay or invest in a place, typically using the city as a catalyst to elevate their socioeconomic standing.
This is fine, but cities will suffer in the next demographic swing. As it stands, most cities are planning for the next 10-20 years using a stable or growing tax base. This is just not true. Tax receipts will not continue to grow, they’ll be more volatile, creating deeper dips and higher spikes in local economies.
Tax receipts, which are used for things like water, health, education, environment, security, business development, and transportation, will (probably) implode.
Detroit (or the entire country of Japan) is a good example of this. Both based their planning goals on false demographics.
So, while most cities are scrambling to provide design solutions, they really should be pivoting towards investing in the people. How? Diversity in education systems. Having a strong public school system is great, creating a system that includes charter, specialty, religious schooling options is even better. Assisting people with their health care options should include increased focus on mental health. Study after study has shown that when people improve their mental health, their physical health and relationships with communities greatly improves. Investment in parks, environmental quality, and conservation areas consistently (in nearly every country) show economic and health resiliency.
Here’s a sweet little report discussing some of these solutions: Demographic change in European cities: City practices for active inclusion.
There are tons of other things, like creating a Happiness Index, which measures how happy people are in the current situations. If there are dips and swings to this index, government can nudge the bar in one direction or the other.
Thanks for the interesting question!