The lifespan of a star depends on how much mass the star has.
Stars feed themselves by turning hydrogen into helium. Through this process, they lose mass.
You could say a star consumes itself to stay alive.
It spends 90 percent of its life consuming itself.
Hot, bright blue giants have more hydrogen turning into helium all at once.
They die fastest, spending only a few million years as a mature star. Cool, dim red dwarfs have less hydrogen. They consume their mass more slowly and can live for billions of years.
The Sun, which is of average size, temperature, and brightness, has shone for about 5 billion years already.
It has another 5 billion years or so to go as a main sequence, or mature star.