The only code that work for me in a Vite React application was this code:

    useEffect(() => {
       document.getElementById('top').scrollIntoView({ behavior: 'smooth' })
    }, []);

 

 

  return (
    <div id="top">
    .....code
    </div>

 

What did not work:

window.scroll({top:0,behavior:'smooth'})

window.scrollTo(0, 0);

document.querySelector('body').scrollTo(0,0)