Apple is on the verge of becoming the first American company to be worth $1 trillion.

Apple is now worth about $945 billion. Shares are up more than 13% this year, far better than the overall market. For Apple to hit a $1 trillion market valuation, the stock would need to go up just another 6% to $202.30 a share.

Even though some think Apple (AAPL) needs a new product to keep sales and profit booming, Apple has inched closer to $1 trillion thanks to solid sales of the iPhone 8 and X -- particularly in China and Japan -- and surging services revenue from the App Store.

Apple's sales increased 16% in the first three months of 2018 -- not bad for a company of its massive size.

It also has been using its more than $267 billion in cash to boost its dividend and stock buyback program as a way of rewarding investors, which include Warren Buffett.

Buffett's Berkshire Hathaway (BRKB)bought nearly 75 million shares of Apple in the first quarter, making it Berkshire's top stock holding.

Related: Apple is showering its investors with cash

But Apple is benefiting from investor euphoria surrounding the tech sector broadly as well.

Amazon (AMZN) is also trading at an all-time high and is now worth more than $800 billion. That's lifted the net worth of Amazon CEO Jeff Bezos to nearly $140 billion, according to lists by Forbes and Bloomberg tracking the world's wealthiest people.

Google owner Alphabet (GOOGL) and Microsoft (MSFT) have rallied to near record highs this year too. They are each now worth more than $775 billion.

Facebook (FB), despite its Cambridge Analytica woes, is not far from its all-time high either. It has a market value of nearly $560 billion.

Apple, Amazon, Google, Microsoft and Facebook are now collectively worth about $3.9 trillion.

But Apple would not be the first publicly traded company in the world to surpass the trillion dollar mark.

Oil giant PetroChina (PTR) briefly topped a trillion dollar valuation in 2007 when its stock began trading in Shanghai, but shares quickly plunged afterward. PetroChina, which is also listed on the New York Stock Exchange, is now worth about $240 billion.