What happened

Shares of Shopify (SHOP -3.15%) charged sharply higher Thursday morning, surging by as much as 27.8%. As of 10:25 a.m. ET, the stock was still up by 25.8%.

The rise was particularly striking as all three of the major U.S. market indexes were in the red Thursday morning. The catalysts that sent the e-commerce platform provider higher were its surprisingly robust first-quarter results and its apparent decision to abandon its logistics aspirations.

So what

Shopify reported its first-quarter results before the opening bell, and shareholders let out a collective cheer. Revenue rose 25% year over year to $1.5 billion, which resulted in a surprise profit, with earnings per share of $0.05. 

To put those results in context, analysts' consensus estimates were for revenue of $1.4 billion and a loss per share of $0.04 -- so Shopify exceeded expectations by a country mile. 

The strong top-line growth was fueled by a 15% increase in gross merchandise volume -- i.e., the total value of products sold on its platform. The results were also boosted by price increases that Shopify announced earlier this year. Those price hikes went into effect for new merchants beginning Jan. 24, and for existing merchants on April 23, so their full impact has yet to be seen.

The company also announced that it will be cutting its workforce by 20%, with some employees being laid off immediately. In a blog post, CEO Tobi Lütke said "I recognize the crushing impact this decision has on some of you, and did not make this decision lightly." 

Finally, the company announced that it is selling its Shopify Logistics business to privately held Flexport, which will become the company's preferred logistics partner. It did not disclose the financial details of the deal.

Now what

For the second quarter, Shopify is guiding for growth of roughly 25% year over year, accompanied by a mid-single-digit percentage decline in operating expenses, excluding the sale of its logistics business. This will help fuel future profits.

The past year has been a tough one for Shopify, but management is positioning the company to succeed over the long term. Each of these moves will make it more nimble, giving it the speed and agility to compete in an ever-changing world.

As such, Shopify stock remains a buy.