Several studies from the United States report an increased risk of prolonged opioid use after shoulder replacement. We aimed to determine the incidence and risk factors of prolonged opioid use after elective shoulder replacement in a nationwide Danish population. All primary elective shoulder arthroplasties reported to the Danish Shoulder Arthroplasty Registry (DSR) from 2004 to 2020 were screened for eligibility. Data on potential risk factors was retrieved from the DSR and the National Danish Patient Registry while data on medication was retrieved from the Danish National Health Service Prescription Database. Prolonged opioid use was defined as 1 or more dispensed prescriptions on and 90 days after date of surgery (Q1) and subsequently 1 or more dispensed prescriptions 91-180 days after surgery (Q2). Preoperative opioid use was defined as 1 or more dispensed prescriptions 90 days before surgery. Logistic regression models were used to estimate risk factors for prolonged opioid use. We included 5,660 patients. Postoperatively 1,584 (28%) patients were dispensed 1 or more prescriptions in Q1 and Q2 and were classified as prolonged opioid users. Among the 2,037 preoperative opioid users and the 3,623 non-opioid users, 1,201 (59%) and 383 (11%) respectively were classified as prolonged users. Preoperative opioid use, female sex, alcohol abuse, previous surgery, high Charlson Comorbidity index, and preoperative use of either antidepressants, antipsychotics, or benzodiazepines were associated with increased risk of prolonged opioid use. The incidence of prolonged opioid use was 28%. Preoperative use of opioids was the strongest risk factor for prolonged opioid use, but several other risk factors were identified for prolonged opioid use.