requestAnimationFrame is a browser API that runs a function right before the browser paints the next frame of an animation. You call it once, it fires once, and calling it again inside the callback creates the loop — synced to your monitor's refresh rate (~60fps). Unlike setInterval, it pauses when the tab is hidden, never tears, and adapts to 120Hz displays automatically.
Animation libraries like Motion use it under the hood — animate() or useSpring is essentially a well-engineered RAF loop with physics and framerate-independence built in.