The Duke of Cambridge said he had been taken on a rollercoaster of emotion after he watched a Tony award-winning musical about the agonies of youth.

The Duke and Duchess of Cambridge spent a night at the theatre as guests of honour at a charity performance of Dear Evan Hansen.

The performance, at the Noel Coward Theatre in London’s West End, was in aid of The Royal Foundation, which is working to encourage more people to talk openly about their mental health and to try to tackle the stigma surrounding the issue.

William told the cast and crew that the show was “amazing” when he and Kate went backstage after the performance.

The show’s title character struggles to fit in and make friends at school and the musical tackles some dark topics such as teenage suicide and relationships.

He told the cast: “To do a production about mental health, it was like ‘how is this going to work?’

“It could go either way. It could be too serious or it is too thin. You nailed it.

“You had the humour and the normalisation of it. You had the sincerity and the authenticity.

“There were so many emotions and feelings and you had the spectrum of it.

“You had the whole rollercoaster of how you feel.”

William and Kate asked the British actors how they managed to keep up their American “twang” throughout the performance, and also about how the musical had increased their personal interest in mental health issues.

A beaming Kate was wearing a black dress by Eponine and a pair of sparkly silver shoes, while William sported a navy suit and tie.

Earlier the couple had a quick chat with some of the talent involved in the production, including composers Justin Paul and Benj Pasek, author Steven Levenson, and producer Stacey Mindich.

In a personal message, which was printed on the back of the programme for the show, William said that mental health is an issue that he and Kate “care passionately” about.

The Duke and Duchess of Cambridge alongside cast members (Ian Vogler/Daily Mirror/PA) Credit: Ian Vogler/Daily Mirror

William also said he and Kate were “pleased that Dear Evan Hansen is helping to start important conversations between parents and teenagers about this important subject.”

He also spoke of his pride that Shout, a mental health support service launched by the Royal Foundation, is one of four not-for-profit partners of the show.

William is currently spearheading a campaign, called Heads Up, in which football teams up and down the country try to help raise awareness of the fact that mental health is just as important as physical health.

It follows on from the Heads Together campaign, which has also been backed by the couple.

This campaign looks to encourage people in Britain to talk openly about mental health and urges anyone to seek help if they need it.

The aim is to try to help “tackle the stigma and change the conversation around mental health” through all these initiatives, according to the message.

The show, which is also playing on Broadway, where it won six Tony Awards, has been a sell-out success since opening in London’s West End late last year.