but still US is a lot richer on a per capita basis
You're correct but this is about wealth not GDP.China passed the USA as the official richest country in the world years ago they just don’t tell you.
What’s measured to compare the economies of China and the US is nominal GDP which is in essence the magnitude of their economies. In this field it’s USA roughly $19 trillion and China roughly $14 trillion.
However this isn’t an accurate and disproportionately favours wealthier nations over second/third class nations since the value of money is much lower in these countries meaning $1 in each country has different value. To top it off China is already known to artificially lower the value of their currency to stay competitive in global trade making the value of money in each country even more different.
A more accurate measurement that takes into account the value of money in each nation is accounting for a countries Purchasing power parity which essentially cancels out the costs of goods in each country revealing the true size of their economies on a level scale. In terms of Purchasing power parity, China has been ahead of the US for quite some time now. Officially passed in 2017 with many speculating much more longer than that. Last I remeber I believe purchasing power parity in US was $21 trillion wheras in China it was $23 trillion. This gap is drastically increasing
Here’s a good article to read regarding this