We study electromagnetic interaction of a nanomagnet with a weak superconducting link. Equations that govern coupled dynamics of the two systems are derived and investigated numerically. We show that the presence of a small magnet in the proximity of a weak link may be detected through Shapiro-like steps caused by the precession of the magnetic moment. Despite very weak magnetic field generated by the weak link, a time-dependent bias voltage applied to the link can initiate a non-linear dynamics of the nanomagnet that leads to the reversal of its magnetic moment. We also consider quantum problem in which a nanomagnet interacting with a weak link is treated as a two-state spin system due to quantum tunneling between spin-up and spin-down states.