• The TRI$\mu$P facility, under construction at KVI, requires the production and separation of short-lived and rare isotopes. Direct reactions, fragmentation and fusion-evaporation reactions in normal and inverse kinematics are foreseen to produce nuclides of interest with a variety of heavy-ion beams from the superconducting cyclotron AGOR. For this purpose, we have designed, constructed and commissioned a versatile magnetic separator that allows efficient injection into an ion catcher, i.e., gas-filled stopper/cooler or thermal ionizer, from which a low energy radioactive beam will be extracted. The separator performance was tested with the production and clean separation of $^{21}$Na ions, where a beam purity of 99.5% could be achieved. For fusion-evaporation products, some of the features of its operation as a gas-filled recoil separator were tested.