Redirect to another route. Useful for protecting routes or redirecting from old paths.
import { Redirect } from 'one'
export default function ProtectedPage() {
const { user } = useAuth()
if (!user) {
return <Redirect href="/login" />
}
return <Dashboard user={user} />
}
| Prop | Type | Description |
|------|------|-------------|
| href | string | The path to redirect to |
The redirect only fires once per mount, even if the screen is focused multiple times (e.g., navigating away and back). This prevents redirect loops in scenarios like authentication guards.
Edit this page on GitHub.