first project commit

This commit is contained in:
2026-05-16 12:02:15 +01:00
parent 33789b13d1
commit c013b52f59
79 changed files with 5834 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
'use client';
import { createTRPCReact } from '@trpc/react-query';
import type { AppRouter } from '@repo/api';
/**
* Typed tRPC React Query hooks for client components.
*
* import { trpc } from '@/lib/trpc/client';
* const { data } = trpc.ping.ping.useQuery();
*/
export const trpc = createTRPCReact<AppRouter>();
+30
View File
@@ -0,0 +1,30 @@
import 'server-only';
import { cache } from 'react';
import { headers } from 'next/headers';
import {
appRouter,
createCallerFactory,
createTRPCContext,
type AppRouter,
} from '@repo/api';
import type { inferRouterInputs, inferRouterOutputs } from '@trpc/server';
import { resolveUser } from '../auth';
/**
* RSC-side tRPC caller. Bypasses HTTP — runs the router directly inside the
* server component. Use this for reads in Server Components / Server Actions.
*
* For client-side reads/mutations, see `./client.ts` (TanStack Query hooks).
*/
const createContext = cache(async () => {
const user = await resolveUser();
const h = await headers();
return createTRPCContext({ user, headers: h });
});
const createCaller = createCallerFactory(appRouter);
export const api = createCaller(createContext);
export type RouterInputs = inferRouterInputs<AppRouter>;
export type RouterOutputs = inferRouterOutputs<AppRouter>;