Media playback is unsupported on your device Media caption Halsey performs Now Or Never at Glastonbury 2017

Pop singer Halsey gave more established names like Katy Perry and Lorde a run for their money at Glastonbury this weekend.

The US singer first gained attention as a social media queen, posting videos on YouTube under her real name Ashley Nicolette Frangipane.

But it's as Halsey (an anagram of her first name) that she's found fame, with a knack for writing gutsy pop songs that explore her flaws and failings.

Her first album, Badlands, went platinum in the US, thanks to its so-called "millennial anthem" New Americana ("We are the new Americana / High on legal marijuana / Raised on Biggie and Nirvana / We know very well / who we are").

Last year, her career received an unexpected shot in the arm thanks to her contribution to The Chainsmokers' ubiquitous hit single, Closer.

Image copyright Getty Images Image caption Halsey teamed up with Chainsmokers for Closer

A masterclass in pop writing, the song wistfully tells the story of a boy and girl bumping into each other in a hotel bar four years after they broke up.

The lyrics, which Halsey co-wrote, bore all the hallmarks of her best work - especially in its vivid depictions of place and time ("so baby pull me closer in the back seat of your Rover").

With one megahit under her belt, she set to work on her new album Hopeless Fountain Kingdom, which has sold 500,000 copies in its first two weeks on sale in the US.

Ahead of her Glastonbury set, the star sat down with BBC News to talk about the record, and how it helped her rediscover her sense of self.

Image copyright EPA / PA

You must have heard of Glastonbury before - but what's it like to see it for the first time?

I mean, I grew up in the middle of a small town in the US and as a kid I knew about Glastonbury. It's like Woodstock. It's massive.

I always dreamed one day I'd get to go, but I never dreamed one day I'd get to play. And I certainly didn't think it would be so soon.

It seems like it's a very kind place, and people are making friends.

You said you didn't think you'd be here so soon - but your album is selling by the bucketload! Has the speed of your success been a surprise?

It was definitely really rapid. The thing about my second album was I kept thinking, "Do people still like me or was the first time an accident?"

But I've met so many amazing fans in the couple of weeks since the release, and everyone keeps telling me they feel so connected to the record. I think as an artist, all you really want out of your album is to feel like you're not alone.

Because you wrote it for a reason. You wrote it because you're feeling some kind of emotion that you had to get out in the world. And if fans say, "that makes me feel like I'm not alone", then you get to say back to them, "Well, you telling me that makes me feel like I'm not alone either".

So it's very mutual. It's a language of love.

The album came from a place of pain and loneliness. To get that result must feel, I guess, both rewarding and strange.

Yeah. The record is really about me going through this prolonged break-up. I'd been in a relationship so long it almost felt like I forgot who I was, when I was alone. And writing this album helped me rediscover that.

Going through that pain and having it turn into something positive that helps other people - you're kind of making lemonade out of lemons.

There's been another recent album about that, hasn't there?

Haha! It's a pretty universal concept in music. It's like, "hey, make me feel less bad about my pain!"

Image copyright Getty Images

Do you ever worry that, if you get happy, you won't have anything to write about?

I've talked about something similar in interviews recently. It can be difficult going through a period of time where you feel depressed because it can become your identifier. In the sense that you wake up, you're depressed; you talk to your friends, you're complaining that you're depressed; you talk to your parents, you're unmotivated.

You know what you could do to try to overcome it - although obviously there's no cure - but you start to feel like, 'what will happen to me if I feel better? Who am I when I'm happy. I'm so used to feeling like this.'

And that was something that I was really going through at the time. And the turnaround is really positive. Who I am is different now, but who I am is better - and I think that's a really good thing.

And of course, there are good songs that come from a place of contentment or positivity. Have you any favourites?

I love '80s happy music. I love Cyndi Lauper and Madonna, and the idea of making music that's about people celebrating fun.

I spent my late adolescence in New York and I used to go to a lot of gay clubs. The music there was always just about love and connection and celebrating life.

I think, for people going through something really hard, to go to a place where you can let loose and listen to music as a distraction, that's about a better place, a better way of life - that's where all the attraction lies.

Like Madonna says: "Only when I'm dancing can I feel this free."

Exactly! Exactly!

For me, I made Closer and that was my first happy record.

Really? That's supposed to be a happy song? I thought it was about a break-up you couldn't get over.

I think it's celebrating a moment in time. The idea of "we're not ever getting older" it's like… at the beginning of the song, you tell the audience we're not together any more. But in the chorus you tell them, 'we'll always be together in that moment. We can always look back on that moment and remember it'.

Image copyright Getty Images

Your new album is called Hopeless Fountain Kingdom. What does that mean?

Hopeless Fountain Kingdom was this phrase that I learned from some people I used to hang out with when I was a teenager. HFK was like a tag, that would get graffittied on malls and things. And when it came to make this record, it just seemed like the perfect name. It just encompassed the feeling I was trying to express.

It's hopeless. There's a sense of eternity - this youthfulness, this fountain, this everflowing chase. And it's a kingdom because I write about places a lot.

The word 'kingdom' occurs a lot in your music

Yeah, the first song on my first record is called Castle and it says, "they've got the kingdom locked up". It's cool to go back and reference that. It's like all the songs and all the albums exist in one Halsey universe.

Speaking of which, I heard you were a big Marvel Nerd. Which comics from the Marvel Universe did you read?

I was a big Spider-Man kid. Big, big on Spider-man and actually, when I first signed my record deal the first thing I wanted to do was track down really rare really expensive comic. I looked everywhere in New York for it and I couldn't find it. I'm still looking for it now. One day I'll get my hands on it.

But I love Deadpool, I love X-Men, I loved Silver Sable, Black Cat - female mercenaries were really cool for me to look up to me growing up.

So the idea of a consistent universe, where the timelines cross and different characters pop into different things, I'd really like to apply that to music, in a way. I'm sure a couple of things from Badlands will pop up in a few HFK music videos down the line. Little Easter Eggs.

I can't think of many other musicians that do that. Maybe the Chili Peppers - they have a character called Dani California that crops up across different songs.

I think that sometimes people fear continuity because it can turn into repetition - and there's a lot of artists who are really good at creating something new all the time. But for me it's about the consistency in my story. Because after all, I'm the protagonist in everything. All the songs are about my life so naturally there will be some connection because I'm still the same person I've always been.

If you could have a super power, what would it be?

I want the power of diagnosis. I want to be able to tell what's wrong with anyone around so I can give them what they need.

Follow us on Facebook, on Twitter @BBCNewsEnts, or on Instagram at bbcnewsents. If you have a story suggestion email entertainment.news@bbc.co.uk.