UNPKG

@logux/client

Version:

Logux base components to build web client

33 lines (29 loc) 655 B
import type { ReadableAtom } from 'nanostores' import type { Client } from '../client/index.js' /** * Auth store. Use {@link createAuth} to create it. */ export interface AuthStore extends ReadableAtom<{ isAuthenticated: boolean userId: string }> { /** * While store is loading initial state. */ readonly loading: Promise<void> } /** * Create store with user’s authentication state. * * ```js * import { createAuth } from '@logux/client' * * let auth = createAuth(client) * await auth.loading * console.log(auth.get()) * ``` * * @param client Logux Client. */ export function createAuth(client: Client): AuthStore