Mexico could be on the verge of a massive economic boom as nearshoring, the process by which companies bring operations closer to their home country, gains traction. Data compiled by real estate group CBRE showed that the area occupied by new nearshoring projects in Mexico totaled 735,000 square meters in 2021. In the first quarter alone, that number grew by 370,000 square meters to more than 1 million square meters. This has already led to a manufacturing surge in Mexico and represents "a lifetime opportunity" to invest in Latin America's second-largest economy, according to Bank of America. What follows is a breakdown of what's driving Mexico's nearshoring boom, and how investors can capitalize on it. The drivers: trade war and Covid Bank of America cited 10 reasons driving nearshoring in Mexico, including the ongoing U.S.-China trade war and the Covid-19 pandemic. The U.S.-China trade war began in 2018, with the U.S. slapping tariffs on a myriad of Chinese imported goods. China then retaliated by imputing levies of its own on U.S. soybean exports . The back-and-forth led to heightened market volatility, and with many U.S. tariffs on Chinese imports still in place, relations between the two countries remain tense. However, it also made Mexico a more attractive country for companies looking to sell products to the U.S. "Initially some market share was won by Taiwan and Vietnam and some other countries, probably as a way to circumvent tariffs, but we are now entering a new phase where we believe movements will be more in response to what is perceived as a structural change in the US-China relationship," Bank of America economists led by Carlos Capistran said in note last week. The Covid outbreak, meanwhile, sparked prolonged factory shutdowns around the world, leading to widespread supply chain disruptions. This, in turn, has led to companies moving operations closer to home to ensure greater control over their supply chains. This represents a big opportunity for Mexico, "given the country's close proximity to the US, as well as some of its established production ecosystems," wrote Morgan Stanley analysts led by Nikolaj Lippmann last month. Other drivers cited by Bank of America include Mexico's large manufacturing base, the U.S.-Mexico-Canada free-trade agreement and the country's relatively low wages. "Nearshoring represents Mexico's best growth opportunity for the next 10 years and it is already occurring," Bank of America's Capistran said. "Mexico's manufacturing sector is booming. It has grown more than 5% year-to-date (ytd) in real terms. It is one of the few sectors that is already above pre-pandemic levels (+6%) and that is growing as a percentage of GDP." How to play the trend: Buy Tesla? There are several ways for the U.S. investors to get exposure to this trend. Perhaps the easiest one is through exchange-traded funds such as the iShares MSCI Mexico ETF ( EWW ). The fund, which has an expense ratio of 0.5%, is designed to follow the broader Mexican stock market. The EWW is up 1.9% in 2022, easily outperforming the S & P 500. Another way of getting exposure is buying Mexican stocks listed in U.S. exchanges. Some of the most traded U.S.-listed Mexican names are cement giant Cemex , telecom company Grupo Televisa , airport operator Grupo Aeroportuario Centro Norte and retail and beverage multinational Fomento Economico Mexicano (Femsa). Grupo Aeroportuario is the best performer of the four names, gaining 20% year to date, followed by Femsa, which is down just 4.9% in that time. Cemex and Televisa have struggled in 2022, losing more than 40% each. For those who don't feel comfortable buying shares of Mexican companies, they can still play the trend by buying U.S. names that have high exposure to Mexico. To find these names, CNBC Pro screened the S & P 1,500 for companies that have at least 15% of their revenue come from Mexico. Topping the list are PriceSmart and car components maker American Axle & Manufacturing . Nearly 48% of PriceSmart's revenue comes from Mexico, according to FactSet, while American Axle sees just under 40% of its sales come from the country. FirstCash Holdings , electronics manufacturer Sanmina and ingredient provider Ingredion also made the list. All five of those stocks are outperforming the S & P 500 this year, with FirstCash jumping nearly 30% and Sanmina popping 38%. PriceSmart and Ingredion are down 6.4% and 8.2%, respectively, in 2022, but that's still better than the S & P 500's 19% drop for the year. American Axle is up 3% this year. Morgan Stanley also pointed to Tesla as a potential beneficiary to this trend. Analyst Adam Jonas, who has an overweight rating on the stock, said: "The confluence of (a) energy transition and the Inflation Reduction Act (IRA) and (b) onshoring appears set to drive the biggest capex cycle of the century — the Mother of All Capex Cycles (aka the MACC)." "In our opinion, Tesla is in position to be the standard-setter of the 'battery industrial age' as it is the 'most' USMCA car company," Jonas said. Tesla shares have struggled this year, losing more than 35% in that time. — CNBC's Michael Bloom contributed to this report.