A new strategy to preserve invariants in the numerical integration of initial value problems with explicit Runge--Kutta methods is presented. It is proved that this technique retains the order of the original method, has an easy and cheap implementation, and can be used in adaptive Runge--Kutta codes. Some numerical experiments with the classical code of Dormand and Prince, DoPri5(4), based on a pair of embedded methods with orders 5 and 4, are presented to show the behavior of the new method for several problems which possess invariants.