@adonis-agora/authkit-react
Version:
Frontend ergonomics over AuthKit for AdonisJS + Inertia + React apps: a typed useAuth() hook, role-gating hooks and gating components.
11 lines (10 loc) • 461 B
JavaScript
import { createElement, Fragment } from 'react';
import { useAuth } from '../use_auth.js';
export function Authenticated({ children, fallback = null }) {
const { isAuthenticated } = useAuth();
return createElement(Fragment, null, isAuthenticated ? children : fallback);
}
export function Guest({ children, fallback = null }) {
const { isAuthenticated } = useAuth();
return createElement(Fragment, null, isAuthenticated ? fallback : children);
}