The nature of the magnetically ordered state and the spin dynamics are at the origin for an understanding of magnetic quantum critical points. Here, neutron scattering as a microscopic probe can give important information on an atomic scale about the magnetic order, the characteristic energy scales of the magnetic interactions and the spin fluctuations close to quantum criticality. The magnetic structure, the critical spin dynamics and its dimensionality directly affect the unusual behavior seen in thermodynamics and transport properties of these compounds. Neutron scattering can also shed light on to the pairing mechanism of unconventional superconductors since spin excitations are a driving force for the Cooper pair formation in these unconventional superconductors. In our research we mainly focus on lanthanide and actinide-based heavy-fermion compounds located near a magnetic instability and study their magnetic ordering phenomena and magnetic excitation spectra in dependence of temperature, external magnetic field, composition and external pressure. Experiments are performed at all major European neutron sources at temperatures down to well below 100 mK and in external magnetic fields in excess of 12 T.