mirror of
https://github.com/gromlab-ru/slm-design.git
synced 2026-08-22 15:30:16 +03:00
20 lines
473 B
TypeScript
20 lines
473 B
TypeScript
'use client'
|
|
|
|
import { useContext } from 'react'
|
|
|
|
import { AuthContext } from '../auth.context'
|
|
import type { AuthContextValue } from '../types/auth-context.type'
|
|
|
|
/**
|
|
* Возвращает application-scoped auth API текущего пользователя.
|
|
*/
|
|
export const useAuth = (): AuthContextValue => {
|
|
const context = useContext(AuthContext)
|
|
|
|
if (context === null) {
|
|
throw new Error('useAuth must be used inside AuthProvider')
|
|
}
|
|
|
|
return context
|
|
}
|