ObjectivesDetermine whether patients who live in greener and more walkable neighbourhoods live longer, and take fewer opioids, following hip or knee arthroplasty.DesignRetrospective cohort study.SettingResidential environment following surgery at one of 54 New Zealand hospitals.ParticipantsAll people who received a total hip or knee arthroplasty at a publicly-funded hospital in New Zealand in 2006 and 2007 (7449 hip arthroplasties and 6558 knee arthroplasties).Primary and secondary outcome measureTime to all-cause mortality and number of postsurgical opioid prescriptions.ResultsPatients who lived in greener neighbourhoods, as measured by the Normalised Difference Vegetation Index, lived longer following hip or knee arthroplasty (standardised OR: 0.95, 95% CI 0.92 to 0.99). However, when we estimated separate hip-arthroplasty-only and knee-arthroplasty-only models, greenness was only significantly associated with greater longevity following hip arthroplasty. Similarly, patients who lived in greener neighbourhoods took fewer opioids in the 12 months following hip or knee arthroplasty (standardised OR: 0.97, 95% CI 0.95 to 0.99), but in separate hip-arthroplasty-only and knee-arthroplasty-only models, greenness was only significantly associated with lower opioid use following hip arthroplasty. Walkability was not significantly associated with postsurgical opioid use or postsurgical longevity. All ORs were adjusted for sex, ethnicity, age, presurgical chronic health conditions, presurgical opioid use, social deprivation and length of hospital stay.ConclusionsConsistent with the literature on enhanced-recovery programme, people who lived in greener neighbourhoods took fewer opioids, and lived longer, following hip arthroplasty. Improving access to the natural environment may therefore be an effective component of postsurgical recovery programme.