;\r\n})\r\n\r\nexport default trpc.withTRPC(MyApp);\r\n```\r\n\r\n#### After\r\n\r\n> Not thrilled about exactly this API-design, but gets the point across that `withTRPC()` can be tree shaken, feel free to do other suggestions\r\n\r\n```ts\r\n// _app.tsx\r\nimport { AppType } from 'next/dist/shared/lib/utils';\r\nimport { trpc } from '~/utils/trpc';\r\nimport { createTRPCNextWithTRPC } from '@trpc/next';\r\n\r\nconst MyApp: AppType = (({ Component, pageProps }) => {\r\n return \u003CComponent {...pageProps} />;\r\n})\r\n\r\nexport default createWithTRPC(trpc)(MyApp);\r\n```\r\n",[3081],{"name":3082,"color":3083},"RFC","78B062",2650,"Break out `withTRPC` from `createTRPCNext`?","2022-11-04T00:06:57Z","https://github.com/trpc/trpc/issues/2650",0.6861065,{"description":3090,"labels":3091,"number":3092,"owner":3023,"repository":3023,"state":3049,"title":3093,"updated_at":3094,"url":3095,"score":3096},"Hello,\r\nI was trying, to migrate my next API to trpc.\r\nI generate trpc cache using createSSGHelpers (because for us need static generation) and in static props request end successfully. But on client I getting the error **TRPCError: No input expected.** I created log in onError in createNextApiHandler, and input is `{ json: null, meta: { values: [ 'undefined' ] } } `. ",[],2068,"Input is not the same schema as expected","2022-10-04T06:09:26Z","https://github.com/trpc/trpc/issues/2068",0.6873705,{"description":3098,"labels":3099,"number":3100,"owner":3023,"repository":3023,"state":3049,"title":3101,"updated_at":3102,"url":3103,"score":3104},"When trying to build my Next.js project, I'm getting the following error:\r\n\r\n```javascript\r\nTRPCClientError: request to http://localhost:3000/api/trpc/post.test?batch=1&input=%7B%220%22%3A%7B%22json%22%3Anull%2C%22meta%22%3A%7B%22values%22%3A%5B%22undefined%22%5D%7D%7D%7D failed, reason: connect ECONNREFUSED ::1:3000\r\n at Function.from (/Users/matthias/Code/nx/agracheck/node_modules/.pnpm/@trpc+client@9.23.2_@trpc+server@9.23.2/node_modules/@trpc/client/dist/TRPCClientError-e9bf96e9.cjs.prod.js:69:14)\r\n at /Users/matthias/Code/nx/agracheck/node_modules/.pnpm/@trpc+client@9.23.2_@trpc+server@9.23.2/node_modules/@trpc/client/links/httpBatchLink/dist/trpc-client-links-httpBatchLink.cjs.prod.js:208:50\r\n at processTicksAndRejections (node:internal/process/task_queues:96:5) {\r\n originalError: FetchError: request to http://localhost:3000/api/trpc/post.test?batch=1&input=%7B%220%22%3A%7B%22json%22%3Anull%2C%22meta%22%3A%7B%22values%22%3A%5B%22undefined%22%5D%7D%7D%7D failed, reason: connect ECONNREFUSED ::1:3000\r\n at ClientRequest.\u003Canonymous> (/Users/matthias/Code/nx/agracheck/node_modules/.pnpm/next@12.1.2_4ee95308deca1889961de2ade43e18f6/node_modules/next/dist/compiled/node-fetch/index.js:1:64142)\r\n at ClientRequest.emit (node:events:527:28)\r\n at Socket.socketErrorListener (node:_http_client:454:9)\r\n at Socket.emit (node:events:527:28)\r\n at emitErrorNT (node:internal/streams/destroy:164:8)\r\n at emitErrorCloseNT (node:internal/streams/destroy:129:3)\r\n at processTicksAndRejections (node:internal/process/task_queues:83:21) {\r\n type: 'system',\r\n errno: 'ECONNREFUSED',\r\n code: 'ECONNREFUSED'\r\n },\r\n shape: undefined,\r\n data: undefined,\r\n isDone: false,\r\n [cause]: FetchError: request to http://localhost:3000/api/trpc/post.test?batch=1&input=%7B%220%22%3A%7B%22json%22%3Anull%2C%22meta%22%3A%7B%22values%22%3A%5B%22undefined%22%5D%7D%7D%7D failed, reason: connect ECONNREFUSED ::1:3000\r\n at ClientRequest.\u003Canonymous> (/Users/matthias/Code/nx/agracheck/node_modules/.pnpm/next@12.1.2_4ee95308deca1889961de2ade43e18f6/node_modules/next/dist/compiled/node-fetch/index.js:1:64142)\r\n at ClientRequest.emit (node:events:527:28)\r\n at Socket.socketErrorListener (node:_http_client:454:9)\r\n at Socket.emit (node:events:527:28)\r\n at emitErrorNT (node:internal/streams/destroy:164:8)\r\n at emitErrorCloseNT (node:internal/streams/destroy:129:3)\r\n at processTicksAndRejections (node:internal/process/task_queues:83:21) {\r\n type: 'system',\r\n errno: 'ECONNREFUSED',\r\n code: 'ECONNREFUSED'\r\n }\r\n}\r\n```\r\n\r\nMy `withTRPC` config looks like this:\r\n```javascript\r\nimport { withTRPC as withOriginalTRPC } from '@trpc/next';\r\nimport superjson from 'superjson';\r\nimport { AppRouter } from '../routers/_app';\r\n\r\nexport const withTRPC = withOriginalTRPC\u003CAppRouter>({\r\n config({ ctx }) {\r\n if (typeof window !== 'undefined') {\r\n // during client requests\r\n return {\r\n url: '/api/trpc',\r\n };\r\n }\r\n // during SSR below\r\n\r\n // optional: use SSG-caching for each rendered page (see caching section for more details)\r\n const ONE_DAY_SECONDS = 60 * 60 * 24;\r\n ctx?.res?.setHeader(\r\n 'Cache-Control',\r\n `s-maxage=1, stale-while-revalidate=${ONE_DAY_SECONDS}`\r\n );\r\n\r\n // The server needs to know your app's full url\r\n // On render.com you can use `http://${process.env.RENDER_INTERNAL_HOSTNAME}:${process.env.PORT}/api/trpc`\r\n const url = process.env.VERCEL_URL\r\n ? `https://${process.env.VERCEL_URL}/api/trpc`\r\n : 'http://localhost:3000/api/trpc';\r\n\r\n return {\r\n url,\r\n /**\r\n * @link https://trpc.io/docs/data-transformers\r\n */\r\n transformer: superjson,\r\n /**\r\n * @link https://react-query.tanstack.com/reference/QueryClient\r\n */\r\n // queryClientConfig: {\r\n // defaultOptions: {\r\n // queries: { suspense: false, useErrorBoundary: true },\r\n // mutations: { useErrorBoundary: true },\r\n // },\r\n // },\r\n headers: () => {\r\n if (ctx?.req) {\r\n // on ssr, forward client's headers to the server\r\n return {\r\n ...ctx.req.headers,\r\n 'x-ssr': '1',\r\n };\r\n }\r\n return {};\r\n },\r\n };\r\n },\r\n /**\r\n * @link https://trpc.io/docs/ssr\r\n */\r\n ssr: true,\r\n});\r\n```\r\n\r\nThis is the Next.js page that throws the error:\r\n```javascript\r\nexport function Index(props: InferGetStaticPropsType\u003Ctypeof getStaticProps>) {\r\n const { data } = trpc.useQuery(['post.test']);\r\n const { t } = useTranslation('common');\r\n\r\n return (\r\n \u003C>\r\n \u003Ch1>\r\n {t('h1')} {data?.test}\r\n \u003C/h1>\r\n \u003CSuspenseBoundary selector=\"post.test\">\r\n \u003Cspan>{JSON.stringify(data)}\u003C/span>\r\n \u003C/SuspenseBoundary>\r\n\r\n \u003CAuth />\r\n \u003C/>\r\n );\r\n}\r\n\r\nexport const getStaticProps: GetStaticProps = async (ctx) => {\r\n const ssg = await createSSGHelpers();\r\n\r\n await ssg.fetchQuery('post.test');\r\n\r\n return {\r\n props: {\r\n trpcState: ssg.dehydrate(),\r\n },\r\n };\r\n};\r\n\r\nexport default Index;\r\n```\r\n\r\nThanks for looking into this!",[],1846,"Error \"TRPCClientError: request failed\" when building a Next.js app","2022-04-28T17:37:27Z","https://github.com/trpc/trpc/issues/1846",0.689654,{"description":3106,"labels":3107,"number":3111,"owner":3023,"repository":3023,"state":3049,"title":3112,"updated_at":3113,"url":3114,"score":3115},"Hi, when I try to use the [NextJS documentation example](https://trpc.io/docs/nextjs), I get an error.\r\n`TypeError: Cannot read properties of null (reading 'client')`\r\nIt's happend in NextJS 12.1.5 version.\r\n\r\nWhen lower version to 12.1.4 everything starts working correctly.",[3108],{"name":3109,"color":3110},"blocked","111111",1789,"Next example is not working in Next 12.1.5","2022-10-04T00:18:13Z","https://github.com/trpc/trpc/issues/1789",0.6914289,{"description":3117,"labels":3118,"number":3119,"owner":3023,"repository":3023,"state":3049,"title":3120,"updated_at":3121,"url":3122,"score":3123},"Hi!\r\n\r\nI have an issue with next project and types. After installing some packages (completely unrelated to trpc) every query now returns \"any\". I've tried reverting all the changes, removing node_modules and installing it again, but all trpc queries returns any and `next build` throws `Parameter '{some variable from trpc.useQuery}' implicitly has an 'any' type`.\r\n\r\nDo you have any ideas what could cause it?\r\n\r\nIt's hard to give example code to reproduce because I used exact configuration as in trpc docs: https://trpc.io/docs/nextjs and it worked fine util I've run `yarn add {something}`\r\n\r\nThanks",[],1916,"Types suddenly breaks","2022-10-04T06:09:15Z","https://github.com/trpc/trpc/issues/1916",0.6926791,{"description":3125,"labels":3126,"number":3127,"owner":3023,"repository":3023,"state":3049,"title":3128,"updated_at":3129,"url":3130,"score":3131},"We are still seeing this issue https://github.com/trpc/trpc/issues/2292:\r\n\r\n```\r\nnode_modules/@trpc/client/src/TRPCClientError.ts:18:19 - error TS2416: Property 'cause' in type 'TRPCClientError\u003CTRouter>' is not assignable to the same property in base type 'Error'.\r\n Type 'Maybe\u003CError>' is not assignable to type 'Error | undefined'.\r\n Type 'null' is not assignable to type 'Error | undefined'.\r\n\r\n18 public readonly cause;\r\n```\r\n\r\nWith the following deps:\r\n\r\n```\r\n \"typescript\": \"4.8.4\",\r\n \"@trpc/client\": \"9.27.2\",\r\n \"@trpc/react\": \"9.27.2\",\r\n \"@trpc/server\": \"9.27.2\",\r\n```\r\n\r\n_Originally posted by @moltar in https://github.com/trpc/trpc/issues/2292#issuecomment-1262366016_\r\n ",[],2851,"Type error with TRPCError & TRPCClientError","2022-10-14T06:21:43Z","https://github.com/trpc/trpc/issues/2851",0.69427395,["Reactive",3133],{},["Set"],["ShallowReactive",3136],{"$fTRc1wZytZ_XrK4EfJfei_Sz-An4H4Yy6syhVxH_PVJc":-1,"$f74AfbW1LLn73A5Nc4NhtAR2yIQyueaTYYa7dSsO878o":-1},"/trpc/trpc/2534"]