UNPKG

@magicbell/react-headless

Version:
54 lines (53 loc) 1.81 kB
import React from 'react'; import { QueryParams } from '../../types/INotificationsStoresCollection.js'; import INotificationStore from '../../types/INotificationStore.js'; type StoreConfig = { id: string; defaultQueryParams: QueryParams; defaults?: Partial<Omit<INotificationStore, 'context'>>; }; export type MagicBellProviderProps = { children: React.ReactElement | React.ReactElement[]; stores?: StoreConfig[]; serverURL?: string; socketURL?: string; disableRealtime?: boolean; network?: { cacheTTL?: number; maxRetries?: number; }; } & ({ apiKey: string; userEmail: string; userKey?: string; token?: never; } | { apiKey: string; userExternalId: string; userKey?: string; token?: never; } | { token: string; apiKey?: never; }); /** * Provider component for Magicbell. * * @param props * @param props.apiKey API key of the MagicBell project * @param props.userEmail Email of the user whose notifications will be displayed * @param props.userExternalId External ID of the user whose notifications will be displayed * @param props.userKey Computed HMAC of the user whose notifications will be displayed, compute this with the secret of the magicbell project * @param props.token User token that can be used to authenticate instead of using the apiKey + userEmail/userExternalID combination * @param props.stores List of stores to be created * @param props.disableRealtime Disable realtime updates * * @example * ```javascript * <MagicBellProvider apiKey={MAGICBELL_API_KEY} userEmail={email}> * <App /> * </MagicBellProvider> * ``` */ export default function MagicBellProvider({ children, stores, disableRealtime, ...clientSettings }: MagicBellProviderProps): React.JSX.Element; export {};