@adonis-agora/authkit-react
Version:
Frontend ergonomics over AuthKit for AdonisJS + Inertia + React apps: a typed useAuth() hook, role-gating hooks and gating components.
17 lines (16 loc) • 640 B
JavaScript
import { createElement } from 'react';
import { useSignOut } from '../hooks/use_sign_out.js';
import { useAuth } from '../use_auth.js';
export function SignOutButton({ children = 'Sair', returnTo, className, ...rest }) {
const { signOut } = useSignOut();
const { isAuthenticated } = useAuth();
if (!isAuthenticated)
return null;
const opts = returnTo ? { returnTo } : undefined;
return createElement('button', {
type: 'button',
className: ['authkit-button', 'authkit-button--ghost', className].filter(Boolean).join(' '),
onClick: () => signOut(opts),
...rest,
}, children);
}