Emulates the browser's scroll restoration on location changes. Apps should only render one of these, right before the Scripts component.
import { ScrollRestoration } from "react-router";export default function Root() { return ( <html> <body> <ScrollRestoration /> <Scripts /> </body> </html> );} Copy
import { ScrollRestoration } from "react-router";export default function Root() { return ( <html> <body> <ScrollRestoration /> <Scripts /> </body> </html> );}
This component renders an inline <script> to prevent scroll flashing. The nonce prop will be passed down to the script tag to allow CSP nonce usage.
<script>
nonce
<ScrollRestoration nonce={cspNonce} /> Copy
<ScrollRestoration nonce={cspNonce} />
Props
A <script> tag that restores scroll positions on navigation.
framework
data
Emulates the browser's scroll restoration on location changes. Apps should only render one of these, right before the Scripts component.
This component renders an inline
<script>to prevent scroll flashing. Thenonceprop will be passed down to the script tag to allow CSP nonce usage.