Background: Recurrent events analysis plays an important role in many applications, including the study of chronic diseases or recurrence of infections. Historically, most models for the analysis of time-to-event data, including recurrent events, have been based on Cox proportional hazards regression. Recently, however, the Piece-wise exponential Additive Mixed Model (PAMM) has gained popularity as a flexible framework for survival analysis. While many papers and tutorials have been presented in the literature on the application of Cox based models, few papers have provided detailed instructions for the application of PAMMs and to our knowledge, none exist for recurrent events analysis. Methods: The PAMM is introduced as a framework for recurrent events analysis. We describe the application of the model to unstratified and stratified shared frailty models for recurrent events. We illustrate how penalized splines can be used to estimate non-linear and time-varying covariate effects without a priori assumptions about their functional shape. The model is motivated for both, analysis on the gap timescale ("clock-reset") and calendar timescale ("clock-forward"). The data augmentation necessary for the application to recurrent events is described and explained in detail. Results: Simulations confirmed that the model provides unbiased estimates of covariate effects and the frailty variance, as well as equivalence to the Cox model when proportional hazards are assumed. Applications to recurrence of staphylococcus aureus and malaria in children illustrates the estimation of seasonality, bivariate non-linear effects, multiple timescales and relaxation of the proportional hazards assumption via time-varying effects. The R package pammtools has been extended to facilitate estimation, visualization and interpretation of PAMMs for recurrent events analysis. Conclusion: PAMMs provide a flexible framework for the analysis of time-to-event and recurrent events data. The estimation of PAMMs is based on Generalized Additive Mixed Models and thus extends the researcher’s toolbox for recurrent events analysis.