{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "auth-redirect",
  "title": "Auth Redirect",
  "description": "A session-aware redirect view that safely continues authenticated users to a same-origin target or sends them through sign in first.",
  "dependencies": [
    "@better-auth-ui/react@latest",
    "@better-auth-ui/core@latest",
    "better-auth"
  ],
  "registryDependencies": [
    "spinner"
  ],
  "files": [
    {
      "path": "src/components/auth/auth-redirect.tsx",
      "content": "\"use client\"\n\nimport { getAuthRedirectAction } from \"@better-auth-ui/core\"\nimport { useAuth, useSession } from \"@better-auth-ui/react\"\nimport { useEffect, useRef } from \"react\"\nimport { Spinner } from \"@/components/ui/spinner\"\nimport { cn } from \"@/lib/utils\"\n\nexport type AuthRedirectProps = {\n  className?: string\n}\n\n/**\n * Redirects authenticated users to a validated same-origin target.\n *\n * Signed-out users are sent through the sign-in view first. The redirect view\n * is preserved as the post-authentication destination so API callbacks receive\n * a full-page request after the session is established.\n *\n * @param className - Optional additional class names applied to the spinner\n * @returns The centered spinner shown while the session and redirect resolve\n */\nexport function AuthRedirect({ className }: AuthRedirectProps) {\n  const { authClient, basePaths, viewPaths } = useAuth()\n  const { data: session, isPending } = useSession(authClient)\n  const hasRedirected = useRef(false)\n\n  useEffect(() => {\n    if (isPending || hasRedirected.current) return\n    hasRedirected.current = true\n\n    const action = getAuthRedirectAction(\n      new URL(window.location.href),\n      Boolean(session),\n      `${basePaths.auth}/${viewPaths.auth.signIn}`\n    )\n\n    window.location.replace(action.to)\n  }, [basePaths.auth, isPending, session, viewPaths.auth.signIn])\n\n  return <Spinner className={cn(\"mx-auto my-auto\", className)} />\n}\n",
      "type": "registry:component",
      "target": "@components/auth/auth-redirect.tsx"
    }
  ],
  "type": "registry:component"
}