With the consumer price index (CPI) rising 8.6% for May, inflation is pressing consumers and businesses alike. You've probably discussed inflation with family, coworkers, and friends, but how do you position a portfolio to take advantage of the current environment?

The key is to purchase shares with a necessary product or that can provide consumers with bargain prices. Three stocks that come to mind are Costco Wholesale (COST 0.84%), CrowdStrike (CRWD 2.30%), and NextEra Energy (NEE 1.57%). These companies span three industries and provide investors diversification when trying to set their portfolios up for dealing with inflation.

Costco

Costco is a warehouse giant that offers bulk discounts to its customers for an annual fee. Consumers dealing with inflation are looking for any type of savings possible, and shopping at Costco helps ease the burden. Additionally, Costco offers gas prices at a discount to regular stations. With gas prices setting new record highs weekly, this is another growth driver for the company.

The big box retailer reported strong results in May with comparable sales rising 10.7% year over year in the U.S. when gasoline prices and foreign exchanges were excluded. If you add in gas, sales rose an incredible 17.5%.

Costco makes most of its money through its membership revenue, so rising prices won't give it a considerable boost. However, with revenue from membership fees rising 9.2% last quarter, that means Costco is still attracting new customers.

Historically, Costco has raised its membership fee every five-and-a-half years, which means another increase should be happening soon. However, management stated in a recent conference call for its latest quarter (ended May 8) that raising fees on its already "burdened client base" wouldn't be the "right time." 

Costco helps consumers fight inflation and looks out for its client base; this creates a loyal following and makes the stock a solid buy, down 26% from its all-time high.

CrowdStrike

Moving to the vital product side of inflation, CrowdStrike provides cybersecurity software to its customers. Cyberattacks are predicted to double by 2025, and businesses must get ahead of this trend before they are hit with a crippling attack. 

CrowdStrike's offering secures network endpoints (like laptops and phones) and is practically a no-brainer investment. Forrester Research found that CrowdStrike's software provided a less than three-month payback and a return on investment (ROI) of 403% when assessed over three years.

With the software providing significant value to clients, it's no wonder CrowdStrike's customer count rose 57% year over year to 17,495 during its latest quarter (ended April 30). Additionally, its annual recurring revenue rose 61% to $1.9 billion over the year-ago period.

CrowdStrike is also free-cash-flow positive, producing $158 million during the quarter. This should allow the company to fund itself even if the lending market begins to sour for unprofitable tech companies.

As it is a subscription business, its customers must keep paying the fee or risk being subjected to a cyberattack. But with the protection and value it provides clients, it's unlikely CrowdStrike will lose customers

NextEra Energy

Another service that consumers can't live without is electricity. NextEra Energy operates in two segments: Florida Power & Light Company (the utility provider for Florida) and NextEra Energy Resources (the world's largest renewable energy generator).

With rising electricity prices, NextEra stands to increase its revenue but must also offset its rising input costs. Still, management sees its adjusted earnings per share rising between 6% and 8% annually through 2025. By 2024, NextEra expects to produce at least double the current renewable energy, which should help profits since renewable energy doesn't have as high of ongoing input costs (like natural gas) as traditional energy sources do.

While it doesn't offer blazing growth, combined with its current 2.3% dividend yield, the stock can still give investors a solid return. Consumers need to keep the lights on, and the appetite for renewable energy by companies looking to transform their carbon footprint remains high. NextEra Energy is a great company that will help keep your investment steady through highs and lows.

All three companies provide vital products to their customer base, which should keep the businesses steady during times of inflation. So while other companies' stocks may suffer, ones that combat inflation should rise strongly as the market eventually recovers from bear market territory.