Pet hamsters generally live for about 2 to 3 years. The lifespan of different hamster breeds varies. For example:

Dwarf Hamsters: Such as the Campbell's dwarf hamster and the Winter White dwarf hamster. Their lifespan is usually between 2 and 2.5 years. Since they are small in size, their physical functions are relatively weak, and their metabolic rate is fast, so they have a shorter lifespan.
Syrian Hamsters (Golden Hamsters): They are larger in size, and their lifespan can generally reach 2.5 to 3 years. Their larger size gives them certain advantages in physiological functions, and their lifespan is relatively longer.
In addition, the factors that affect the lifespan of hamsters include:
The Raising Environment: A suitable living environment is crucial for the health and lifespan of hamsters. Hamsters need enough space for activities, appropriate temperature and humidity, and a clean living environment. For instance, Syrian hamsters require a cage with a minimum size of 30×30×30 centimeters. The temperature should be maintained between 18 and 26 degrees Celsius, and the humidity should be between 40% and 60%.
Diet: A balanced diet is essential for the health of hamsters. A hamster's diet should include high-quality hamster food, an appropriate amount of fresh vegetables and fruits, as well as clean drinking water. Feeding a single type of food for a long time will lead to an unbalanced diet, which will affect their health and lifespan.
Health and Genetic Factors: Genetic defects can affect the lifespan of hamsters. If the parents of a hamster have genetic defects, the probability of their offspring having health problems will increase, and their lifespan will also be affected.