AimsTo evaluate the sleep quality of patients with atrial fibrillation and its influencing factors, and explore whether illness perception mediates the relationship between family function and sleep quality.DesignCross‐sectional survey conducted from November 2020 to November 2021.MethodsA total of 191 participants validly completed the Pittsburgh Sleep Quality Index, the Family APGAR Index and the Brief Illness Perception Questionnaire. Data were analysed using descriptive statistics, independent samples t‐tests, one‐way ANOVA, Pearson correlation analysis and multiple linear regression analysis. Bootstrapping was used to detect the mediating role of illness perception.ResultsPatients with atrial fibrillation reported poor sleep quality, good family function and a moderate level of illness perception. The better the family function, the lower the level of illness perception and the better sleep quality in patients with atrial fibrillation. Patients with commercial medical insurance had lower levels of sleep quality relative to self‐financed patients. EHRA III and EHRA IV patients had worse sleep quality than EHRA II patients. Illness perception played a significant mediating role in the relationship between family function and sleep quality.ConclusionsPatients with atrial fibrillation have poorer sleep quality, and the type of medical insurance and EHRA score are independent indicators related to their sleep quality. Future health education and interventions need to focus on strengthening and improving the emotional support of family members in order to improve family function and reduce illness perception, thereby improving sleep quality of patients with atrial fibrillation.ImpactThis study provides further evidence that nurses need to enhance their awareness and provide ongoing education to better identify patients with AF who have family dysfunction and perceived high levels of illness threat perceptions, as these factors negatively impact sleep quality.Reporting MethodThis study was reported in strict compliance with the strengthening the reporting of observational studies in epidemiology (STROBE) guideline.Patient or Public ContributionNo patient or public contribution.