If you're searching for new stocks to add to your portfolio, initial public offerings (IPOs) can be a tempting option.

An IPO occurs when a company begins offering shares of stock to the public, and it can be an exciting time for investors who want to get in on the ground floor, so to speak. IPOs offer investors the chance to buy a company's stock for the very first time. If that company ends up thriving and its stock price soars, early investors could stand to make a lot of money.

That said, IPOs can be risky, too. Not all IPOs will succeed over the long term, so it's important to make sure you know what you're getting into before you invest.

By doing as much research as you can on recent IPOs -- including these three companies that went public in October -- it will help determine whether they're the right investment for you.

Person smiling looking at a computer

Image source: Getty Images.

1. GitLab (GTLB)

GitLab (GTLB -1.59%) officially went public on Oct. 14, priced at $77 per share. In the day following its IPO, its share price increased by nearly 11%.

The software company specializes in streamlined solutions, allowing developers to collaborate on projects more efficiently through a single platform. It was launched in 2011, and since then it has built a community of more than 30 million users. It's also a pioneer in the field of remote work, with more than 1,500 remote employees across 66 countries.

2. Portillo's (PTLO)

Portillo's (PTLO -4.06%), a Chicago-based fast-casual restaurant, began trading on Oct. 21 for a price of $20 per share.

The company announced its plans to go public over the summer, and the capital it raised from its IPO could help the restaurant chain continue to expand. It currently has 67 locations across nine states, and it also ships its food across the country through its website. The company aims to grow to more than 600 locations within the next 25 years, according to a filing with the U.S. Securities and Exchange Commission.

3. Cognition Therapeutics (CGTX)

Cognition Therapeutics (CGTX -1.36%) went public on Oct. 8 with a stock price of $12 per share. The company raised approximately $45 million as a result of its IPO, and it's currently valued at around $258 million.

The biopharmaceutical company was launched in 2007, and it aims to find solutions to central nervous system disorders such as Alzheimer's disease, Parkinson's disease, and dementia.

Should you invest in IPOs?

IPOs may be attractive to investors looking for exciting new stocks, but it's important to weigh the risks and rewards before you buy.

The best investments are the ones that perform well over the long term. Because IPOs are so new to the market, it can be tough to determine how they'll fare over time -- especially when many companies are over-hyped leading up to their IPO.

Stock prices will also often fluctuate wildly during the weeks and months following a company's IPO, and a strong start doesn't necessarily mean the stock will continue performing well in the future.

If you're considering a particular IPO, it's wise to start doing as much research as you can now. Keep your eye on the stock, and if it's still a strong investment in six months or a year, then you may decide to buy. By waiting just a little longer to invest, that will give you more time to determine whether it's truly a smart long-term investment.

IPOs are exciting, but they can also be risky. While there's no harm in keeping up with the latest additions to the stock market, it's important to stay focused on the long term and only invest in quality stocks that will perform well over time.