BackgroundPancreatic cancer is an extremely malignant disease that poses a serious threat to the mental health of patients. Many cancer patients now use social media for online social support. However, the impact of social media on mental health is currently inconsistent in the academic community. Therefore, this study aimed to examine the mediating effects of online social support and psychological resilience in the relationship between social media use and mental health of pancreatic cancer patients.MethodsFour hundred and twenty-five valid questionnaires were collected through convenience sampling. All data were processed using SPSS 26.0 and AMOS 26.0. We examine the influence relationships among latent variables by constructing a structural equation model. Then SPSS Process Macro was used to test the chain mediating effect of the model.ResultsThe results showed that (1) anxiety situations occurred in 22.2% of participants (N= 94), while the incidence of depression was 20.2% (N= 86). (2) Social media use positively influenced online social support (β= 0.990,p< 0.001), psychological resilience (β= 0.504,p< 0.001), and mental health (β= 0.330,p< 0.001); online social support positively influenced psychological resilience (β= 0.535,p< 0.001) and mental health (β= 0.354,p< 0.001); psychological resilience significantly and positively influenced mental health (β= 0.243,p< 0.001). (3) The chain mediating effect of online social support and psychological resilience was significant at 0.253 with a confidence interval of [0.178, 0.340].ConclusionPancreatic cancer patients in China are exposed to a high burden of anxiety and depression, which requires urgent attention. Meanwhile, online social support and psychological resilience played a chain mediating role between social media use and mental health (anxiety and depression), and our results provide new insights and ways to support the mental health improvement of pancreatic cancer patients.