Redirect to another route. Useful for protecting routes or redirecting from old paths.
| Prop | Type | Description |
|---|---|---|
href | string | The path to redirect to |
<Redirect> navigates with router.replace as soon as it mounts. It’s designed to be rendered conditionally from a layout guard, so it guards against the two ways that can otherwise turn into a redirect loop:
<Redirect> and <Slot>/null while auth state settles remounts <Redirect> repeatedly, and each remount is a fresh instance. Because router.replace is async (it preloads the target route before dispatching), every remount would otherwise fire another concurrent navigation and throw Maximum update depth exceeded. <Redirect> shares an in-flight guard across instances so only one navigation is dispatched until it lands; the guard clears once it settles, so a later redirect to the same href still fires.Because of this you don’t need a hand-rolled useEffect + useRef redirect in layout guards. Prefer the declarative <Redirect>.
Edit this page on GitHub.