JA
ベータ版の翻訳

@yohangel / auth-react

1.0.0 ▾
MIT
GitHub

Better Auth 用 React ログイン UI:2FA 付きサインイン、サインアップ、ソーシャルボタン、フック

コード6 ファイルコンテキスト約 468 トークンスキャン合格

.genpmignore 適用後に組み込まれる正確なツリーです。固定先:

src/lib/auth-react/guard.tsx読み取り専用 · 7145b9d
// Guardas de cliente. Solo afectan a lo que se ve: la autorización real siempre se comprueba en el servidor.
import type { ReactNode } from 'react';
import { authClient, useSession } from './client.js';

/** Muestra `children` con sesión; sin ella, `fallback` (p. ej. <SignInForm/> o un enlace a /sign-in). */
export function SignedIn({ children, fallback = null, loading = null }: { children: ReactNode; fallback?: ReactNode; loading?: ReactNode }) {
  const { data, isPending } = useSession();
  if (isPending) return <>{loading}</>;
  return <>{data ? children : fallback}</>;
}

export function SignOutButton({ children = 'Sign out', redirectTo = '/' }: { children?: ReactNode; redirectTo?: string }) {
  return (
    <button
      type="button"
      onClick={() =>
        void authClient.signOut({ fetchOptions: { onSuccess: () => window.location.assign(redirectTo.startsWith('/') ? redirectTo : '/') } })
      }
    >
      {children}
    </button>
  );
}

@yohangel/auth-react を報告

パッケージを報告するには GitHub でログインしてください。

GitHub で続ける