Ariana Grande has thanked Justin Bieber for joining her for a surprise duet at Coachella, saying his performance was “the dopamine we be needing”.

Pop heartthrob Bieber joined Grande onstage at the festival in Indio, California, on Sunday.

The star performed his hit Sorry, after telling the crowd the unplanned appearance was his first stage performance in around two years.

“I had to get my groove back, my swag back,” said Bieber, who has recently opened up about going through a tough time.

Grande has now shared a clip from the performance on Instagram.

“Sometimes this is just the dopamine we be needing tbh,” she said.

“Always a pleasure, my friend @justinbieber.

“I’m so proud of u it’s insane.”

Bieber replied: “Thank you thank you.”

Earlier, the singer thanked Grande and the festival on Twitter.

He tweeted: “Thank you @ArianaGrande.

“Thank you @coachella.

“That felt right. Love you.”