Introduction To explore the prevalence of depressive symptoms and the associated risk factors in frontline nurses under COVID-19 pandemic. Methods This cross-sectional study was conducted from February 20, 2020 to March 20, 2020 and involved 562 frontline nurses. The effective response rate was 87.68%. After propensity score matched, there were 498 participants left. Extensive characteristics, including demographics, dietary habits, life-related factors, work-related factors, and psychological factors were collected based on a self-reported questionnaire. Specific scales measured the levels of sleep quality, physical activity, depressive symptoms, perceived organization support and psychological capital. Adjusted odds ratios and 95% confidence intervals were determined by binary paired logistic regression. Results Of the nurses enrolled in the study, 50.90% had depressive symptoms. Three independent risk factors were identified: poor sleep quality (OR = 1.608, 95% CI: 1.384–1.896), lower optimism of psychological capital (OR = 0.879, 95% CI: 0.805–0.960) and no visiting friend constantly (OR = 0.513, 95% CI: 0.286–0.920). Conclusions This study revealed a considerable high prevalence of depressive symptoms in frontline nurses during the COVID-19 outbreak, and identified three risk factors, which were poor sleep quality, lower optimism of psychological capital, and no visiting friend constantly. Protecting mental health of nurses is important for COVID-19 pandemic control and their wellbeing. These findings enrich the existing theoretical model of depression and demonstrated a critical need for additional strategies that could address the mental health in frontline nurses for policymakers.