Real-time hybrid simulation (RTHS) is recently applied to study the vibration of the vehicle–bridge coupling system, where bridges and the vehicle are the numerical and experimental substructures respectively. Inevitable time delay of the boundary loading imposed to the experimental substructure will greatly affect the accuracy and stability of RTHS. To minimize the time delay effects, this paper proposes a recursive prediction optimal (RPO) compensator based on optimal control and recursive least squares. The numerical simulation of the RTHS of the vehicle–bridge coupling system is conducted using MATLAB/Simulink. The performance of the RPO method is compared with three traditional time delay compensation methods (i.e. the polynomial extrapolation (NI), the inverse compensation (IC) and the derivative feedforward (DF)) through both open-loop and RTHS simulations. The RPO method shows the best compensation performance in the frequency range up to 20[Formula: see text]Hz.