{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "auth",
  "title": "Auth",
  "description": "A unified authentication component that renders the appropriate auth view based on path or view prop.",
  "dependencies": [
    "@better-auth-ui/react@latest",
    "@better-auth-ui/core@latest"
  ],
  "registryDependencies": [
    "https://better-auth-ui.com/r/radix-nova/auth-provider.json",
    "https://better-auth-ui.com/r/radix-nova/sign-in.json",
    "https://better-auth-ui.com/r/radix-nova/sign-up.json",
    "https://better-auth-ui.com/r/radix-nova/forgot-password.json",
    "https://better-auth-ui.com/r/radix-nova/reset-password.json",
    "https://better-auth-ui.com/r/radix-nova/verify-email.json",
    "https://better-auth-ui.com/r/radix-nova/auth-redirect.json",
    "https://better-auth-ui.com/r/radix-nova/sign-out.json"
  ],
  "files": [
    {
      "path": "src/components/auth/auth.tsx",
      "content": "\"use client\"\n\nimport type { AuthView } from \"@better-auth-ui/core\"\nimport { useAuth } from \"@better-auth-ui/react\"\nimport { type ComponentType, useEffect } from \"react\"\n\nimport { AuthRedirect } from \"./auth-redirect\"\nimport { ForgotPassword } from \"./forgot-password\"\nimport type { SocialLayout } from \"./provider-buttons\"\nimport { ResetLinkSent } from \"./reset-link-sent\"\nimport { ResetPassword } from \"./reset-password\"\nimport { SignIn } from \"./sign-in\"\nimport { SignOut } from \"./sign-out\"\nimport { SignUp } from \"./sign-up\"\nimport { VerifyEmail } from \"./verify-email\"\n\nexport type AuthProps = {\n  className?: string\n  path?: string\n  socialLayout?: SocialLayout\n  socialPosition?: \"top\" | \"bottom\"\n  /** @remarks `AuthView` */\n  view?: AuthView\n}\n\n/**\n * Built-in views that only make sense when email + password auth is enabled.\n * When it's disabled, the `<Auth>` router redirects these to `signIn` so a\n * plugin's `fallbackViews.auth.signIn` (e.g. magic link) takes over.\n */\nconst PASSWORD_ONLY_VIEWS = [\n  \"signUp\",\n  \"forgotPassword\",\n  \"resetPassword\",\n  \"resetLinkSent\"\n]\n\nconst AUTH_VIEWS: Partial<Record<AuthView, ComponentType<AuthProps>>> = {\n  redirect: AuthRedirect,\n  signIn: SignIn,\n  signOut: SignOut,\n  signUp: SignUp,\n  forgotPassword: ForgotPassword,\n  resetPassword: ResetPassword,\n  resetLinkSent: ResetLinkSent,\n  verifyEmail: VerifyEmail\n}\n\n/**\n * Render the appropriate authentication view based on the provided `view` or `path`.\n *\n * Resolution order:\n *   1. Plugin overrides (`plugin.views.auth[currentView]`) — first registered wins.\n *   2. Plugin fallbacks (`plugin.fallbackViews.auth.signIn`) when password auth is off.\n *   3. Built-in views.\n *\n * @param path - Route path used to resolve an auth view when `view` is not provided\n * @param socialLayout - Social layout to apply to sign-in/sign-up/magic-link views\n * @param socialPosition - Position for social buttons (`\"top\"` or `\"bottom\"`)\n * @param view - Explicit auth view to render (e.g., `\"signIn\"`, `\"signUp\"`)\n * @returns The React element for the resolved authentication view\n */\nexport function Auth({\n  className,\n  path,\n  socialLayout,\n  socialPosition,\n  view\n}: AuthProps) {\n  const { basePaths, emailAndPassword, plugins, viewPaths, navigate } =\n    useAuth()\n\n  if (!view && !path) {\n    throw new Error(\"[Better Auth UI] Either `view` or `path` must be provided\")\n  }\n\n  const authView =\n    view ||\n    (Object.keys(viewPaths.auth) as AuthView[]).find(\n      (key) => viewPaths.auth[key] === path\n    )\n\n  // When email + password auth is disabled, password-only views (signUp,\n  // forgotPassword, resetPassword) have no meaning. Redirect them to signIn,\n  // where a plugin's `fallbackViews.auth.signIn` (e.g. magic link) takes\n  // over as the primary entry point.\n  const shouldRedirectToSignIn =\n    !emailAndPassword?.enabled &&\n    authView &&\n    PASSWORD_ONLY_VIEWS.includes(authView)\n\n  useEffect(() => {\n    if (shouldRedirectToSignIn) {\n      navigate({\n        to: `${basePaths.auth}/${viewPaths.auth.signIn}`,\n        replace: true\n      })\n    }\n  }, [shouldRedirectToSignIn, navigate, basePaths.auth, viewPaths.auth.signIn])\n\n  if (shouldRedirectToSignIn) {\n    return null\n  }\n\n  // 1. Plugin overrides (`views.auth[currentView]`) — first plugin wins,\n  //    including over built-in views. Resolves the view key from `view`,\n  //    then `authView` (built-in path match), then plugin-introduced paths\n  //    (e.g. `magicLink` → `/auth/magic-link`).\n  for (const plugin of plugins) {\n    const pluginAuthPaths = plugin.viewPaths?.auth\n\n    const pluginView =\n      view ??\n      authView ??\n      (pluginAuthPaths &&\n        Object.keys(pluginAuthPaths).find(\n          (key) => pluginAuthPaths[key] === path\n        ))\n    if (!pluginView) continue\n\n    const PluginView = plugin.views?.auth?.[pluginView]\n    if (!PluginView) continue\n\n    return (\n      <PluginView\n        className={className}\n        socialLayout={socialLayout}\n        socialPosition={socialPosition}\n      />\n    )\n  }\n\n  // 2. Plugin fallbacks — only when the built-in `signIn` isn't viable\n  //    (password auth is off). Used by `magicLinkPlugin` to render the\n  //    magic-link form as the primary passwordless sign-in surface.\n  if (authView === \"signIn\" && !emailAndPassword?.enabled) {\n    const Fallback = plugins.find(\n      (plugin) => plugin.fallbackViews?.auth?.signIn\n    )?.fallbackViews?.auth?.signIn\n\n    if (Fallback) {\n      return (\n        <Fallback\n          className={className}\n          socialLayout={socialLayout}\n          socialPosition={socialPosition}\n        />\n      )\n    }\n  }\n\n  const AuthView = authView ? AUTH_VIEWS[authView] : undefined\n\n  if (!AuthView) {\n    throw new Error(\n      `[Better Auth UI] Unknown view \"${authView}\". Valid views are: ${Object.keys(AUTH_VIEWS).join(\", \")}`\n    )\n  }\n\n  return (\n    <AuthView\n      className={className}\n      socialLayout={socialLayout}\n      socialPosition={socialPosition}\n    />\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/auth/auth.tsx"
    }
  ],
  "type": "registry:component"
}