scrimba
Learn React Router
Actions
redirectTo - part 1
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

redirectTo - part 1
AboutCommentsNotes
redirectTo - part 1
Expand for more info
Protected.jsx
run
preview
console
import React from "react"
import { redirect, Outlet } from "react-router-dom"
import { requireAuth } from "./requireAuth"

export async function loader({ request }) {
const url = new URL(request.url)
await requireAuth()
return null
}

export default function Protected() {
return (
<>
<h1>Super secret info here</h1>
<Outlet />
</>
)
}
Console
"/protected"
,
"/protected/nested"
,
/login
-4:21