Abstract Background Heart failure (HF) frequently causes an imbalance in heart and kidney functions, and the prognosis of heart and kidney disease can worsen one another. In addition to the prognostic role of chronic kidney disease (CKD), dynamic changes in renal function have been recognized to portend a poor prognosis in HF patients. Purpose This study aimed to investigate the prevalence of impaired renal function at HF diagnosis and its association with short and long-term outcomes in a real-world cohort of HF patients. In addition, we assessed how dynamic changes in renal function after HF diagnosis might predict HF prognosis. Methods Using a natural language processing algorithm, clinical data of patients with at least one diagnosis of HF (index event) were retrospectively collected. Patients for which the most recent estimated glomerular filtration rate (eGFR) value prior to the index date was ≤ 60 mL/min/1.73m2 and/or had a documented medical history of CKD (including dialysis) were considered as having CKD. A linear mixed effects model was used to show the longitudinal eGFR trajectories during the follow-up period (after index). A Cox proportional hazard model was used to analyse the association between baseline variables and mortality. Finally, joint modelling was used to combine the linear mixed eGFR sub-model with the survival sub-model, to estimate the effect of the current eGFR value and the eGFR slope of the year prior on mortality. Results The study population consisted of 1992 patients with a mean (±SD) age of 74.8 ± 11.7 years and 58% males. In total, 17% had HF with preserved ejection fraction (HFpEF, n = 339) and 70% (n = 1156) presented CKD at the index event. The median follow-up time was 3.16 years and 13% (n = 198) of the patients were deceased after two years. The group of 2-year survivors had significantly lower proportion of CKD at index (55 vs 76%, p < 0.001). The calculated mean yearly decrease of the eGFR value was 4.2 mL/min/1.73m². The multivariate Cox PH model identified age, CVA, diastolic blood pressure, HDL, and log10proBNP as baseline predictors of mortality. Joint modelling showed that a 10 mL/min/1.73m2 lower current eGFR value amongst patients was associated with an increased mortality hazard of 1.30 ± 0.06 (p < 0.001). Additionally, a decrease of 10 mL/min/1.73m2 in eGFR during the year prior indicated an increased mortality hazard of 1.87 ± 0.19 (p < 0.001). Conclusion In a real-world cohort of HF patients, the prevalence of CKD is high and CKD is an independent predictor of mortality. The current eGFR value and the year prior’s eGFR slope adds additional prognostic information and helps to better fine tune the individual mortality hazard. Based on the findings of this analysis, patients with worse prognosis might benefit from a closer and more vigilant follow-up.