Specta LogoSpecta
RspcTypescript apiTs rspc react

@rspc/react

TypeScript API reference for @rspc/react, version 1.0.0-rc.1.

Public exports of @rspc/react at version 1.0.0-rc.1.

This page documents 1.0.0-rc.1. The documented version is 0.2.2.

Interfaces

BaseOptions

interface BaseOptions<TProcedures extends ProceduresDef> {
    rspc?: {
        client?: AlphaClient<TProcedures>;
    };
}

View source ↗

Context

interface Context<TProcedures extends ProceduresDef> {
    client: AlphaClient<TProcedures>;
    queryClient: QueryClient;
}

View source ↗

SubscriptionOptions

interface SubscriptionOptions<TOutput> {
    enabled?: boolean;
    onStarted?: () => void;
    onData: (data: TOutput) => void;
    onError?: (err: RSPCError | Error) => void;
}

View source ↗

Type aliases

HooksOpts

type HooksOpts<P extends ProceduresDef> = {
    context: React.Context<Context<P>>;
};

View source ↗

Functions

createReactQueryHooks

declare function createReactQueryHooks<P extends ProceduresDef>(client: AlphaClient<P>, opts?: HooksOpts<P>): {
    _rspc_def: P;
    Provider: ({ children, client, queryClient, }: {
        children?: ReactElement<any, string | react.JSXElementConstructor<any>> | undefined;
        client: AlphaClient<P>;
        queryClient: QueryClient;
    }) => react_jsx_runtime.JSX.Element;
    useContext: () => Context<P>;
    useQuery: <K extends P["queries"]["key"] & string, TQueryFnData = inferQueryResult<P, K>, TData = inferQueryResult<P, K>>(keyAndInput: [
        key: K,
        ...input: _inferProcedureHandlerInput<P, "queries", K>
    ], opts?: (Omit<UseQueryOptions<TQueryFnData, RSPCError, TData, [
        K,
        inferQueryInput<P, K>
    ]>, "queryKey" | "queryFn"> & BaseOptions<P>) | undefined) => UseQueryResult<TData, RSPCError>;
    useMutation: <K_1 extends P["mutations"]["key"] & string, TContext = unknown>(key: K_1 | [
        K_1
// … truncated, see the source link

View source ↗

Re-exports

QueryClient

QueryClient

View source ↗

QueryClientProvider

QueryClientProvider

View source ↗

On this page