Specta LogoSpecta
RspcTypescript apiTs rspc react

@rspc/react

TypeScript API reference for @rspc/react, version 0.0.0-main-7c0a67c1.

Public exports of @rspc/react at version 0.0.0-main-7c0a67c1.

This page documents 0.0.0-main-7c0a67c1. The documented version is 0.2.2.

Interfaces

BaseOptions

interface BaseOptions<TProcedures extends ProceduresDef> {
    rspc?: {
        client?: Client<TProcedures>;
        abortOnUnmount?: boolean;
    };
}

View source ↗

Context

interface Context<TProcedures extends ProceduresDef, TQueries extends ProcedureDef, TMutations extends ProcedureDef, TSubscriptions extends ProcedureDef> {
    client: Client<TProcedures, TQueries, TMutations, TSubscriptions>;
    queryClient: QueryClient;
}

View source ↗

SubscriptionOptions

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

View source ↗

Functions

createReactHooks

declare function createReactHooks<TBaseProcedures extends ProceduresDef = never, TQueries extends ProcedureDef = TBaseProcedures["queries"], TMutations extends ProcedureDef = TBaseProcedures["mutations"], TSubscriptions extends ProcedureDef = TBaseProcedures["subscriptions"]>(hookOpts?: HookOptions): {
    createClient: any;
    useContext: () => Context<any, any, any, any>;
    Provider: ({ children, client, queryClient, }: {
        children?: ReactElement<any, string | react.JSXElementConstructor<any>> | undefined;
        client: {
            _rspc_def: {
                queries: any;
                mutations: any;
                subscriptions: any;
            };
            query: <K extends any>(keyAndInput: [
                key: K
            ] | [
                K,
                any
            ], opts?: _rspc_client.TRPCRequestOptions | undefined) => Promise<any>;
            mutation: <K_1 extends any>(keyAndInput: [
                key: K_1
            ] | [
// … truncated, see the source link

View source ↗

internal_createReactHooksFactory

declare function internal_createReactHooksFactory(): {
    Provider: ({ children, client, queryClient, }: {
        children?: ReactElement<any, string | react.JSXElementConstructor<any>> | undefined;
        client: Client<any, any, any, any>;
        queryClient: QueryClient;
    }) => JSX.Element;
    createClient: (opts: ClientArgs) => {
        _rspc_def: {
            queries: any;
            mutations: any;
            subscriptions: any;
        };
        query: <K extends any>(keyAndInput: [
            key: K
        ] | [
            K,
            any
        ], opts?: _rspc_client.TRPCRequestOptions | undefined) => Promise<any>;
        mutation: <K_1 extends any>(keyAndInput: [
            key: K_1
        ] | [
            K_1,
            any
        ], opts?: _rspc_client.TRPCRequestOptions | undefined) => Promise<any>;
        subscription: <K_2 extends any>(keyAndInput: [
            key: K_2
        ] | [
            K_2,
            any
// … truncated, see the source link

View source ↗

Re-exports

internal:__useMutation

useMutation as __useMutation

View source ↗

internal:__useQuery

useQuery as __useQuery

View source ↗

On this page