Among the many possible probes to study the quark–gluon plasma (QGP), a high energy-density medium formed in relativistic heavy-ion collisions, heavy quarks are particularly interesting as they are expected to be produced in the initial stages of the collisions, by hard partonic scatterings, and to experience the full evolution of the medium. In particular, charmonia (bound $c\bar{c}$ states) have been measured in nucleus-nucleus collisions with high precision at the LHC leading to the observation of new signatures of deconfinement such as the regeneration of $c\bar{c}$ pairs into charmonium states.

In this contribution, the latest ALICE results on the $ \mathrm {J/\psi} $ nuclear modification factor ($R_{\text{AA}}$) in Pb–Pb collisions at $\sqrt{s_{\mathrm{NN}}}= $ 5.02 TeV will be presented as a function of centrality, $p_{\text{T}}$ and rapidity. This will be complemented by a discussion of the recent results on the elliptic and triangular flow coefficients of inclusive $ \mathrm {J/\psi} $ which can be inherited from flowing charm quarks. In addition, results on $ \mathrm {J/\psi} $ and $\psi(2S)$ measurements in p–Pb collisions at $\sqrt{s_{\mathrm{NN}}}=$ 5.02 and 8.16 TeV will be presented as a tool to study cold nuclear matter effects which may alter the quarkonium production in heavy-ion collisions regardless of the QGP formation. All the shown results will be compared to various theoretical calculations.