}\n \u003C/Provider>\n {/* \u003C/TRPCProvider> */}\n \u003C/QueryClientProvider>\n );\n};\n\nexport default AppProvider;\n```\n\n**React Query**\n```typescript\nimport {\n defaultShouldDehydrateQuery,\n QueryClient,\n} from \"@tanstack/react-query\";\nimport SuperJSON from \"superjson\";\n\nexport const createQueryClient = () =>\n new QueryClient({\n defaultOptions: {\n queries: {\n // With SSR, we usually want to set some default staleTime\n // above 0 to avoid refetching immediately on the client\n staleTime: 360 * 1000,\n },\n dehydrate: {\n serializeData: SuperJSON.serialize,\n shouldDehydrateQuery: (query) =>\n defaultShouldDehydrateQuery(query) ||\n query.state.status === \"pending\",\n },\n hydrate: {\n deserializeData: SuperJSON.deserialize,\n },\n },\n });\n````\n\n**Page.tsx**\n```typescript\n\"use client\";\nimport { api } from \"@c/Provider\";\n// import { useTRPC } from \"@c/Provider\";\nimport { useSession } from \"@hwa/client\";\n// import { useQuery } from \"@tanstack/react-query\";\nimport { useRouter } from \"next/navigation\";\n\nconst Home = () => {\n const router = useRouter();\n const session = useSession();\n // const trpc = useTRPC();\n // const { data } = useQuery(trpc.message.getMessage.queryOptions());\n const { data } = api.message.getMessage.useQuery(); // message is undefined\n return (\n \u003Cdiv className=\"\">\n \u003Cp>{data}\u003C/p>\n \u003Cpre\n style={{\n padding: \"10px\",\n fontFamily: \"monospace\",\n whiteSpace: \"pre-wrap\",\n }}\n >\n {JSON.stringify(session, null, 2)}\n \u003C/pre>\n \u003Cbutton\n className=\"rounded border px-6 py-1\"\n onClick={() => router.refresh()}\n >\n Refresh\n \u003C/button>\n \u003C/div>\n );\n};\n\nexport default Home;\n\n```\n\n### Link to reproduction\n\nhttps://github.com/SamJbori/hwaTurbo\n\n### To reproduce\n\nCreate a split BE and FE with Turbo Repo\n\n### Additional information\n\n_No response_\n\n### 👨👧👦 Contributing\n\n- [ ] 🙋♂️ Yes, I'd be down to file a PR fixing this bug!",[3195],{"name":3185,"color":3186},6933,"bug: createTRPCReact return undefined routers on split FE/BE","2025-09-06T23:01:14Z","https://github.com/trpc/trpc/issues/6933",0.62662417,{"description":3202,"labels":3203,"number":3208,"owner":3175,"repository":3175,"state":3176,"title":3209,"updated_at":3210,"url":3211,"score":3212},"### Provide environment information\r\n\r\nSystem:\r\n OS: Windows 11 10.0.22631\r\n CPU: (20) x64 13th Gen Intel(R) Core(TM) i5-13600K\r\n Memory: 19.64 GB / 31.75 GB\r\n Binaries:\r\n Node: 20.16.0 - C:\\Program Files\\nodejs\\node.EXE\r\n npm: 10.8.1 - C:\\Program Files\\nodejs\\npm.CMD\r\n pnpm: 9.7.0 - C:\\Program Files\\nodejs\\pnpm.CMD\r\n Browsers:\r\n Edge: Chromium (127.0.2651.74)\r\n Internet Explorer: 11.0.22621.3527\r\n npmPackages:\r\n typescript: catalog: => 5.5.4\r\n\r\n### Describe the bug\r\n\r\nAs done in [create-t3-turbo](https://github.com/t3-oss/create-t3-turbo), when emitting `.d.ts` files, \u003Ckbd>ctrl\u003C/kbd>+\u003Ckbd>L Click\u003C/kbd>ing on a nested router/proc will take you to the root router, at least in a monorepo. Issue [here](https://github.com/t3-oss/create-t3-turbo/issues/1124).\r\n\r\nNot a tRPC bug, but you might have an idea how to solve this if possible. Or we can take this to TypeScript repo itself instead.\r\n\r\n### Link to reproduction\r\n\r\nAny fresh `create-t3-turbo` clone\r\n\r\n### To reproduce\r\n\r\n1. Clone `create-t3-turbo`.\r\n2. Install deps.\r\n3. Put a random string for each env variable in `.env.example`.\r\n4. Run `build` or `dev` to generate `dist` folders.\r\n5. Go to `apps/nextjs/src/app/page.tsx` and go to definition from what's currently line 15:\r\n```ts\r\nvoid api.post.all.prefetch();\r\n```\r\n\r\n### Additional information\r\n\r\n_No response_\r\n\r\n### 👨👧👦 Contributing\r\n\r\n- [ ] 🙋♂️ Yes, I'd be down to file a PR fixing this bug!",[3204,3207],{"name":3205,"color":3206},"blocked","111111",{"name":3185,"color":3186},5933,"bug: Go to definition fails when emitting declaration files","2025-03-20T15:42:31Z","https://github.com/trpc/trpc/issues/5933",0.63183326,{"description":3214,"labels":3215,"number":3216,"owner":3175,"repository":3175,"state":3217,"title":3218,"updated_at":3219,"url":3220,"score":3221},"### Provide environment information\r\n\r\n``` \r\nSystem:\r\n OS: macOS 12.2.1\r\n CPU: (10) arm64 Apple M1 Max\r\n Memory: 131.52 MB / 32.00 GB\r\n Shell: 3.2.57 - /bin/bash\r\n Binaries:\r\n Node: 18.8.0 - ~/.local/share/nvm/v18.8.0/bin/node\r\n Yarn: 1.22.19 - ~/.local/share/nvm/v18.8.0/bin/yarn\r\n npm: 8.18.0 - ~/.local/share/nvm/v18.8.0/bin/npm\r\n Browsers:\r\n Chrome: 106.0.5249.103\r\n Firefox: 105.0.2\r\n Safari: 15.3\r\n npmPackages:\r\n @trpc/client: ^10.0.0-proxy-beta.17 => 10.0.0-proxy-beta.17\r\n```\r\n\r\n\r\n### Describe the bug\r\n\r\nTypescript can't complete the typing of a query, see discussion https://github.com/trpc/trpc/discussions/2963\r\n\r\n\r\n`Property 'subscribe' does not exist on type 'DecoratedProcedureRecord\u003Cunknown, BuildProcedure\u003C\"subscription\", { _config: RootConfig\u003C{ ctx: {}; meta: {}; errorShape: never; transformer: CombinedDataTransformer; }>; _ctx_out: {}; _input_in: unique symbol; _input_out: unique symbol; _output_in: u\r\n nique symbol; _output_out: unique symbol; _meta: {}; }, Observable\u003C....'.`\r\n\r\n### Link to reproduction\r\n\r\nhttps://github.com/Lilja/trpc-v10-server-needed\r\n\r\n### To reproduce\r\n\r\nOpen up `src/index.ts` and modify the `type {AppRouter}` import, point it to the trpc repo OR a another router.\r\n\r\n### Additional information\r\n\r\n_No response_\r\n\r\n### 👨👧👦 Contributing\r\n\r\n- [ ] 🙋♂️ Yes, I'd be down to file a PR fixing this bug!",[],2972,"closed","bug: @trpc/server needed in the frontend for types to work","2022-10-11T08:18:00Z","https://github.com/trpc/trpc/issues/2972",0.61746955,{"description":3223,"labels":3224,"number":3226,"owner":3175,"repository":3175,"state":3217,"title":3227,"updated_at":3228,"url":3229,"score":3230},"### Provide environment information\n\nSystem:\n OS: Windows 11 10.0.26100\n CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz\n Memory: 18.28 GB / 31.87 GB\nBinaries:\n Node: 22.11.0 - C:\\Program Files\\nodejs\\node.EXE\n npm: 11.3.0 - C:\\Program Files\\nodejs\\npm.CMD\n pnpm: 8.9.2 - ~\\AppData\\Local\\pnpm\\pnpm.EXE\n bun: 1.2.16 - ~\\.bun\\bin\\bun.EXE\nBrowsers:\n Edge: Chromium (135.0.3179.66)\n Internet Explorer: 11.0.26100.1882\nnpmPackages (server):\n @trpc/server: ^11.4.2 => 11.4.2 \n typescript: ^5.8.3 => 5.8.3\nnpmPackages (client):\n @trpc/client: ^11.4.2 => 11.4.2 \n @trpc/server: ^11.4.2 => 11.4.2 \n typescript: ^5.8.3 => 5.8.3\n\n### Describe the bug\n\nAs discussed with a maintainer in **Discussion #6829**, I'm opening this issue to report a type-leakage bug.\n\nWhen a server-only type (like an instance of a `pino` logger) is included in the tRPC `Context`, its type definition leaks to the client when importing the `AppRouter`. This causes TypeScript compilation to fail on the client-side because it cannot resolve the server-only dependency.\n\nThe expected behavior is that the client-side type inference for `AppRouter` should not be affected by non-serializable, server-only objects within the `Context`. The maintainer in the discussion confirmed that the context is not supposed to leak, which suggests this is unintended behavior.\n\nThe primary errors observed on the client are:\n1. A type portability error `ts(2742)` on the `createTRPCClient` call, explicitly mentioning the server's `pino` module.\n2. A type constraint failure on the `AppRouter` generic, indicating a module path mismatch between the server's and client's versions of `@trpc/server` due to the polluted context type. (Not visible in repro repo)\n\n### Link to reproduction\n\nhttps://github.com/matvejs16/trpc-type-leak\n\n### To reproduce\n\n1. Clone the reproduction repository: `git clone https://github.com/matvejs16/trpc-type-leak.git`\n2. Navigate into the project directory: `cd trpc-type-leak`\n3. Install all dependencies in `client` and `server`: `npm install`\n4. Open the project in a TypeScript-aware editor like VS Code.\n5. Navigate to the file: `client/src/tRPC.ts`.\n6. You will immediately see TypeScript errors highlighted on the `client` variable declaration, demonstrating the type-leak issue. No need to run the application, as this is a compile-time/type-checking error.\n\n### Additional information\n\nThe core of the issue seems to be that the inferred type of `AppRouter` includes the full, non-portable type definition of the `Context` object. In the reproduction, the `Context` contains a `requestLogger` property typed as `pino.Logger`. Because the `client` package does not have `pino` as a dependency, TypeScript rightfully fails to resolve the type.\n\nThis issue is likely to affect anyone working in a monorepo who attempts to integrate common server-side tools like loggers, database clients, or other class-based services directly into the tRPC context.\n\n### 👨👧👦 Contributing\n\n- [ ] 🙋♂️ Yes, I'd be down to file a PR fixing this bug!",[3225],{"name":3185,"color":3186},6830,"bug: Server-only types in Context leak to the client, causing type portability errors","2025-06-24T10:26:28Z","https://github.com/trpc/trpc/issues/6830",0.62196654,{"description":3232,"labels":3233,"number":3240,"owner":3175,"repository":3175,"state":3217,"title":3241,"updated_at":3242,"url":3243,"score":3244},"Hello all,\r\n\r\nI'm trying to set up a demo monorepo full ESM + TypeScript and I want to use trpc for the API part. 👌 \r\nI currently have an issue when generating declaration types for the project:\r\n\r\n```\r\nsrc/router.ts:6:14 - error TS2742: The inferred type of 'appRouter' cannot be named without a reference to '../../../node_modules/@trpc/server/dist/internals/procedure.js'. This is likely not portable. A type annotation is necessary.\r\n```\r\n\r\nRelated code is here: https://github.com/jgoux/acme/blob/main/apps/api/src/router.ts#L6\r\n\r\nTo reproduce run these commands:\r\n```bash\r\nyarn\r\nyarn workspace @acme/api build\r\n```\r\n\r\nNote that I'm using `@trpc/server@10.0.0-alpha.22`, the stable version wasn't correctly importable with ESM, discussion about it here: https://discord.com/channels/867764511159091230/894984069291581511/979830057994432522\r\n\r\nWhat's funny is that the `tsc --noEmit` is fine and doesn't report the error. 😂 \r\n\r\nI'm not sure what to do about this particular TS error, this is a new one to me. 🤔 ",[3234,3237],{"name":3235,"color":3236},"wontfix","ffffff",{"name":3238,"color":3239},"🔎 needs more investigation/info","d4c5f9",1945,"Error TS2742 when generating declaration types with trpc.router","2022-10-04T06:08:55Z","https://github.com/trpc/trpc/issues/1945",0.62273705,{"description":3246,"labels":3247,"number":3248,"owner":3175,"repository":3175,"state":3217,"title":3249,"updated_at":3250,"url":3251,"score":3252},"### Provide environment information\r\n\r\n```\r\n\r\n System:\r\n OS: macOS 12.5.1\r\n CPU: (8) arm64 Apple M1\r\n Memory: 157.83 MB / 16.00 GB\r\n Shell: 5.8.1 - /bin/zsh\r\n Binaries:\r\n Node: 16.17.0 - ~/.nvm/versions/node/v16.17.0/bin/node\r\n Yarn: 1.22.19 - /opt/homebrew/bin/yarn\r\n npm: 8.19.1 - ~/.nvm/versions/node/v16.17.0/bin/npm\r\n Watchman: 2022.09.12.00 - /opt/homebrew/bin/watchman\r\n Browsers:\r\n Brave Browser: 106.1.44.105\r\n Chrome: 105.0.5195.125\r\n Firefox: 105.0.1\r\n Safari: 16.0\r\n npmPackages:\r\n @trpc/react: ^10.0.0-proxy-beta.15 => 10.0.0-proxy-beta.15\r\n react: 18.0.0 => 18.0.0 \r\n typescript: ~4.7.4 => 4.7.4 \r\n\r\n```\r\n\r\n### Describe the bug\r\n\r\nIf I create a trpc react proxy and client like:\r\n\r\n```typescript\r\nexport const trpc = createTRPCReact\u003CUserRouter>()\r\nexport const trpcClient: TRPCClient\u003CUserRouter> = trpc.createClient({\r\n links: [\r\n httpBatchLink({\r\n url: \"http://localhost:3000/user\"\r\n }),\r\n ],\r\n})\r\n```\r\n\r\nAnd try to use the `trpcClient` directly, it does not have the correct types:\r\n\r\n```typescript\r\n const createAccountResult = await trpcClient.mutation(\"account.create\")\r\n```\r\n\r\nWill return: `TS2345: Argument of type 'string' is not assignable to parameter of type 'never'.`\r\n\r\n### Link to reproduction\r\n\r\nhttps://stackblitz.com/github/trpc/examples-next-minimal-starter\r\n\r\n### To reproduce\r\n\r\nSee above\r\n\r\n### Additional information\r\n\r\n_No response_\r\n\r\n### 👨👧👦 Contributing\r\n\r\n- [X] 🙋♂️ Yes, I'd be down to file a PR fixing this bug!",[],2922,"bug: `TRPCClient` from `createTRPCReact\u003CRouterType>().createClient` is incorrectly typed","2022-10-05T23:29:07Z","https://github.com/trpc/trpc/issues/2922",0.6235682,{"description":3254,"labels":3255,"number":3257,"owner":3175,"repository":3175,"state":3217,"title":3258,"updated_at":3259,"url":3260,"score":3261},"### Provide environment information\n\n```\n System:\n OS: Windows 11 10.0.26100\n CPU: (20) x64 13th Gen Intel(R) Core(TM) i5-13600KF\n Memory: 42.13 GB / 63.81 GB\n Binaries:\n Node: 20.18.3 - C:\\Program Files\\nodejs\\node.EXE\n npm: 10.8.2 - C:\\Program Files\\nodejs\\npm.CMD\n Browsers:\n Edge: Chromium (133.0.3065.69)\n Internet Explorer: 11.0.26100.1882\n npmPackages:\n typescript: ^5.8.2 => 5.8.2\n```\n\n### Describe the bug\n\nThe output type file references `@trpc/server/dist/unstable-core-do-not-import` but it's not declared in `package.json`\n\n\n\nI can't get the corret inferenced types from type files.\n\n\n\nIt can be fixed with\n\nserver/package.json\n```diff\n\"exports\": {\n...\n+ \"./dist/*\": {\n+ \"import\": \"./dist/*.mjs\",\n+ \"require\": \"./dist/*.js\",\n+ \"default\": \"./dist/*.js\"\n+ }\n}\n```\nOr the import path should be changed to `@trpc/server/unstable-core-do-not-import` without the `dist` part since `unstable-core-do-not-import` is exported in `package.json`\n\n\n\n### Link to reproduction\n\nhttps://stackblitz.com/edit/vitejs-vite-g9btbcfw?file=dist%2Ftypes%2Fapp-router.d.ts&view=editor\n\n### To reproduce\n\n`npm run build` and check *dist/types/app-router.d.ts*\n\n### Additional information\n\n_No response_\n\n### 👨👧👦 Contributing\n\n- [x] 🙋♂️ Yes, I'd be down to file a PR fixing this bug!",[3256],{"name":3185,"color":3186},6644,"bug: Missing `dist` exports from package.json","2025-03-28T15:45:58Z","https://github.com/trpc/trpc/issues/6644",0.6257721,{"description":3263,"labels":3264,"number":3269,"owner":3175,"repository":3175,"state":3217,"title":3270,"updated_at":3271,"url":3272,"score":3273},"### Provide environment information\n\n```\nSystem:\n OS: macOS 15.3\n CPU: (8) arm64 Apple M2\n Memory: 2.18 GB / 24.00 GB\n Shell: 3.2.57 - /bin/sh\n Binaries:\n Node: 22.12.0 - /usr/local/bin/node\n npm: 11.0.0 - /usr/local/bin/npm\n pnpm: 9.15.4 - /usr/local/bin/pnpm\n Browsers:\n Brave Browser: 132.1.74.48\n Safari: 18.3\n npmPackages:\n @tanstack/react-query: ^5.65.1 => 5.65.1 \n @trpc/client: 11.0.0-rc.730 => 11.0.0-rc.730+776d07336 \n @trpc/react-query: 11.0.0-rc.730 => 11.0.0-rc.730+776d07336 \n @trpc/server: 11.0.0-rc.730 => 11.0.0-rc.730+776d07336 \n next: 15.1.6 => 15.1.6 \n react: ^19.0.0 => 19.0.0 \n typescript: ^5 => 5.7.3 \n```\n\n### Describe the bug\n\nI write protected `procedures` and throwing error from middleware-\n\n```\nimport { initTRPC, TRPCError } from \"@trpc/server\";\n\n//Context\nimport { Context } from \"./context\";\n\n\nconst t = initTRPC.context\u003CContext>().create();\n\nexport const router = t.router;\nexport const procedure = t.procedure.use(\n async function isAuthed(opts) {\n const { ctx } = opts;\n if (!ctx.user) {\n throw new TRPCError({ code: \"UNAUTHORIZED\", message: \"Unauthorized request. Please login\" })\n }\n return opts.next({\n ctx: {\n user: ctx.user\n }\n })\n }\n);\nexport const publicProcedure = t.procedure;\nexport const createCallerFactory = t.createCallerFactory;\n```\n\nHere I throw error for unauthorized request. There this is createContext-\n\nimport { getSession } from \"../auth/next-auth\";\n\nexport const createContext = async () => {\n const user = await getSession();\n return user;\n}\n\nexport type Context = Awaited\u003CReturnType\u003Ctypeof createContext>>;\n\nAnd on a now server page component-\nI just prefetch one request-\n\n```\n//TRPC\nimport { trpc, HydrateClient } from \"@/trpc/server\";\n\nconst Page = async () => {\n //TRPC\n await trpc.unavailability.list.prefetch();\n\n return (\n \u003CHydrateClient>\n \u003CList />\n \u003C/HydrateClient>\n );\n};\n\nexport default Page;\n```\nAll is working on local development is perfect. But when I try to build it-\n\n```\nError occurred prerendering page \"/unavailability\". Read more: https://nextjs.org/docs/messages/prerender-error\nTRPCClientError: Unauthorized request. Please login\n at s.from (/vercel/path0/.next/server/chunks/949.js:3:83107)\n at /vercel/path0/.next/server/chunks/949.js:3:89907\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\nExport encountered an error on /(dashboard)/unavailability/page: /unavailability, exiting the build.\n ⨯ Static worker exited with code: 1 and signal: null\n ELIFECYCLE Command failed with exit code 1.\nError: Command \"pnpm run build\" exited with 1\n\n```\n\n\nSo, it is natural that on build time, there is no authentications. But it stopping to build it-\n\n\n\n\n### Link to reproduction\n\nhttps://github.com/wegreet/dashboard-new-design\n\n### To reproduce\n\nJust build it with vercel\n\n### Additional information\n\n_No response_\n\n### 👨👧👦 Contributing\n\n- [ ] 🙋♂️ Yes, I'd be down to file a PR fixing this bug!",[3265,3268],{"name":3266,"color":3267},"👻 invalid","e4e669",{"name":3185,"color":3186},6441,"bug: TRPC with nextjs 15(App Router) production build failed!","2025-02-05T17:24:47Z","https://github.com/trpc/trpc/issues/6441",0.6292492,["Reactive",3275],{},["Set"],["ShallowReactive",3278],{"$fTRc1wZytZ_XrK4EfJfei_Sz-An4H4Yy6syhVxH_PVJc":-1,"$fO7GJH4dSvRZjyuSpOC5nDqyu58YIdmRz16E1zoaAdDE":-1},"/trpc/trpc/6753"]