context.ts664 BView on GitHub

1 error span on 0 routes in the last 7 days.

/**
 * TRPC Context - Isolated for HMR stability
 *
 * This file creates the TRPC React context and should RARELY be modified.
 * Keeping this separate prevents HMR from recreating the context during
 * development, which would cause "useTRPC() can only be used inside of a
 * <TRPCProvider>" errors.
 *
 * DO NOT add additional logic to this file - keep it minimal and stable.
 */
import { createTRPCContext } from '@trpc/tanstack-react-query';
import type { AppRouter } from '@zero/server/trpc';

// Create the TRPC context once - this should never be re-created during HMR
export const { TRPCProvider, useTRPC, useTRPCClient } = createTRPCContext<AppRouter>();