The current evidence regarding the relationship between sunlight exposure and dementia is limited and inconclusive, with potential modifiers and underlying mechanisms remaining largely unexplored. A total of 499,627 participants from the UK Biobank were included in the study. Sunshine duration and other meteorological exposures for each participant were estimated using the bilinear interpolation approach and time-weighted method. The association between sunshine duration and incident dementia was assessed using the time-dependent Cox proportional hazard model and generalized propensity score model. Multiplicative and additive interaction models were employed to identify the potential modifying effects of sociodemographic, lifestyle, environmental, and genetic factors. Brain age was predicted using machine learning methods based on neuroimaging phenotypes. The individual and joint parallel mediating effects of serum vitamin D, calcium, and brain age acceleration were further assessed using causal mediation analysis. With an average follow-up of 12.3 years, 7636 incident dementia cases were identified. Shorter sunshine duration was found to be associated with increased incidence of dementia with a hazard ratio of 1.05 (95% CI: 1.03, 1.07) for a 10-h decrease in average monthly sunshine duration. The adverse impact of reduced sunshine duration was modified by age, smoking status, household income, and time spent outdoors. The decrease in sunshine duration was also positively associated with brain age acceleration. The mediating effects of serum vitamin D, calcium, and brain age acceleration were estimated to be 16.20% (95% CI: 8.45%, 24.00%), 6.77% (95% CI: 4.01%, 9.78%), and 7.95% (95% CI: 6.48%, 9.00%), respectively, with a combined mediating proportion of 35.2%. Reduced sunshine duration associates positively with incident dementia and the brain aging process. Serum vitamin D, calcium, and brain age acceleration appear to serve as the underlying mechanism mediating the adverse impacts of reduced sunshine duration on dementia. The elderly, smokers, individuals with lower household income, and those with less time spent outdoors should be particularly vigilant.



