UNPKG

@realm/react

Version:

React specific hooks and implementation helpers for Realm

29 lines 1.44 kB
import React from "react"; import type { Realm } from "realm"; /** * Create a context containing the Realm app. Should be accessed with the useApp hook. */ export declare const UserContext: React.Context<Realm.AnyUser | null>; type UserProviderProps = { /** * The fallback component to render if there is no authorized user. This can be used * to render a login screen or another component which will log the user in. */ fallback?: React.ComponentType<unknown> | React.ReactElement | null | undefined; children: React.ReactNode; }; /** * React component providing a Realm user on the context for the sync hooks * to use. A `UserProvider` is required for an app to use the hooks. */ export declare const UserProvider: React.FC<UserProviderProps>; /** * Hook to access the currently authenticated Realm user from the * {@link UserProvider} context. The user is stored as React state, * so will trigger a re-render whenever it changes (e.g. logging in, * logging out, switching user). * */ export declare const useUser: <FunctionsFactoryType extends Realm.DefaultFunctionsFactory = Realm.DefaultFunctionsFactory, CustomDataType extends Record<string, unknown> = Record<string, unknown>, UserProfileDataType extends Realm.DefaultUserProfileData = Realm.DefaultUserProfileData>() => Realm.User<FunctionsFactoryType, CustomDataType, UserProfileDataType>; export {}; //# sourceMappingURL=UserProvider.d.ts.map