@orcestr/auth-react
v0.4.1
Published
React Query provider and hooks for Orcestr authentication.
Maintainers
Readme
@orcestr/auth-react
Headless React Query bindings для @orcestr/auth-core. Пакет не зависит от UI kit и routing
framework.
Установка
npm install @orcestr/auth-core @orcestr/auth-react @tanstack/react-queryИспользование
Разместите provider внутри QueryClientProvider приложения:
import { AuthProvider, useCurrentUser, useLogout } from '@orcestr/auth-react';
export function Providers({ children }) {
return <AuthProvider client={authClient}>{children}</AuthProvider>;
}
export function ProfileAction() {
const user = useCurrentUser();
const logout = useLogout();
// Используйте собственные UI и router.
}AuthProvider принимает структурный AuthClientContract из @orcestr/auth-core. Существующий
browser AuthClient по-прежнему подходит напрямую, а native-приложение может передать IPC-backed
реализацию с теми же login, registration, recovery и provider OAuth методами.
Hooks
useCurrentUser, useLogin, useRegister, useLogout,
usePasswordResetRequest, usePasswordResetConfirm, useEmailVerification и
useAuthClient.
Страницы, navigation callbacks и визуальные компоненты остаются в consumer. Готовые формы
доступны отдельно в @orcestr/auth-forms.
