Image source: Getty Images.

The solar industry is full of both opportunities and risks for investors, which is what makes it such a volatile place to invest. But if you keep an eye on the long-term picture and invest in companies with durable competitive advantages, this can be an industry with trillions of dollars in potential. Here are three companies you can buy now and hold for decades to come.

The diversification play

SunPower (SPWR -2.17%) is known as the manufacturer of the most efficient solar panels in the industry. That helps lower the overall cost of solar energy by lowering the cost for land, wiring, labor, and other costs per watt of energy installed. But that's only where the company's advantages begin.

As a high efficiency supplier, SunPower is able to compete in every segment of the solar market. It supplies cells for handheld solar chargers all the way up to the biggest solar power plants in the world. And it's built a global business, which allows it to take advantage of markets where solar economics are strong, no matter where they are.

Investors shouldn't overlook the company's balance sheet and ability to develop projects itself. SunPower has $1.7 billion in debt, but that's funding $1.2 billion in project assets, as well as the panel making business. And there's another $623.2 million in cash on the balance sheet as well. 

Given the technology advantage over competitors, solid balance sheet, ability to develop projects, and the global reach of SunPower's business, this is a company that should be a great investment for years to come. 

Image source: Getty Images.

The original solar power player

One of the few solar companies that's managed to report consistent profitability over the past decade is First Solar (FSLR -2.09%), though it suffered a short lapse when the market collapsed. Like SunPower, it has technology that's differentiated from that of competitors.

FSLR Cash and Equivalents (Quarterly) Chart

FSLR Cash and Equivalents (Quarterly) data by YCharts

First Solar isn't the most efficient solar panel producer in the industry, but its newest thin film panels are more efficient than most solar panels coming from China, and perform better in most extreme environments. And with solar going into deserts and hot and humid environments, that creates an advantage.

What First Solar does is focus on the utility scale solar market, offering a low cost solution to utilities and large corporate customers. Since it designs the whole solution, it can lower costs across the board and also develop projects on its own. This is what creates the opportunity for profitability you see above.

With technology improving and First Solar's strong balance sheet (see the cash level above), I don't see how the company doesn't maintain a strong position as a project developer for years to come. And that should keep the profits rolling in for investors.

A leading yieldco play

Yieldcos were supposed to be a valuable financing tool for renewable energy companies. If the cost of capital (dividend yield and the interest rate on debt) was low enough, they could theoretically issue new capital and buy projects in perpetuity. But falling stock prices and rising dividends have left the industry weak, and there's even evidence that yieldcos have been used to prop up their sponsors (in the case of TerraForm's yieldco and sponsor SunEdison). 

8point3 Energy Partners (CAFD) is a different kind of yieldco because it has solar assets with a long performance history, a very conservative balance sheet, and two sponsors that keep each other in check. Those sponsors just happen to be the two companies above -- SunPower and First Solar. 

The current dividend yield of 8point3 Energy Partners shares of 5.6% is also high enough to be attractive for investors and low enough that new shares can be issued to buy projects accretively. And that will add to the dividend, which management expects to grow 12%-15% annually. 

8point3 Energy Partners doesn't have the risk, or the potential, of SunPower or First Solar, but it's a safe dividend stock for long-term investors, which makes it a great buy in solar.