Loading article…
ReferenceReact provider and hook API

DocsLoading article…
These declarations are generated by TypeScript from the same code used by the example applications.
import { type ReactNode } from 'react';
import { QueryClient, type QueryKey } from '@tanstack/react-query';
import { QBClient, type Session, type ChannelOptions } from '@qbflex/client';
export interface QBProviderProps {
client: QBClient<any, any>;
queryClient?: QueryClient;
children: ReactNode;
}
/** Supply a stable client created outside rendering, or once with useState. */
export declare function QBProvider({ client, queryClient, children }: QBProviderProps): import("react").JSX.Element;
export declare function useQBClient<D = any, R = any>(): QBClient<D, R>;
export declare function useQBAuth(): {
session: Session | null;
user: {
id: string;
email: string;
name: string;
} | null;
isLoading: boolean;
error: Error | null;
signIn: (input: Parameters<(input: {
email: string;
password: string;
}) => Promise<{
user: any;
token: any;
}>>[0]) => Promise<{
user: any;
token: any;
}>;
signUp: (input: Parameters<(input: {
email: string;
password: string;
name: string;
}) => Promise<{
user: any;
token: any;
} | null>>[0]) => Promise<{
user: any;
token: any;
} | null>;
signInWithMagicLink: (email: string, options?: {
callbackURL?: string;
redirectTo?: string;
}) => Promise<{
status: boolean;
}>;
signOut: () => Promise<void>;
refresh: () => Promise<Session | null>;
passkey: {
enroll: (opts?: {
name?: string;
}) => Promise<unknown>;
list: () => Promise<unknown[]>;
remove: (id: string) => Promise<void>;
rename: (id: string, name: string) => Promise<void>;
signIn: () => Promise<{
user: any;
token: any;
} | null>;
};
};
export declare function useQBQuery<T, D = any>(options: {
queryKey: QueryKey;
queryFn: (client: QBClient<D>, signal: AbortSignal) => PromiseLike<T>;
enabled?: boolean;
}): import("@tanstack/react-query").UseQueryResult<T, Error>;
export declare function useQBSearch(options: {
collection: string;
q: string;
limit?: number;
cursor?: string;
enabled?: boolean;
}): import("@tanstack/react-query").UseQueryResult<import("./contracts/index").Result<{
hits: {
id: string;
table: string;
rank: number;
snippet: string | null;
row: Record<string, unknown>;
}[];
count: number | null;
cursor: string | null;
}>, Error>;
export declare function useQBMutation<T, V, D = any>(options: {
mutationFn: (client: QBClient<D>, variables: V) => Promise<T>;
invalidate?: QueryKey[];
}): import("@tanstack/react-query").UseMutationResult<T, Error, V, unknown>;
export declare function useQBRealtime(options: ChannelOptions & {
enabled?: boolean;
invalidate?: QueryKey[];
}): {
status: string;
};
export declare function useQBStorage(): {
isPending: boolean;
error: Error | null;
upload: (bucket: string, key: string, file: Blob, options?: (import("@qbflex/client").RequestOptions & {
checksum?: string;
}) | undefined) => Promise<import("./contracts/index").Result<{
id: string;
state: string;
}>>;
download: (id: string, options?: import("@qbflex/client").RequestOptions | undefined) => Promise<Blob>;
remove: (id: string, options?: import("@qbflex/client").RequestOptions | undefined) => Promise<import("./contracts/index").Result<{
deleted: boolean;
}>>;
list: (bucket: string) => Promise<import("./contracts/index").Result<any[]>>;
};