Spoeky
TRPC with Nextjs 13 App Router
Im trying to implement TRPC with my already existing Nextjs 13 App to get typesafe API's. I've managed to get it to work in Client Components, meaning i can make the API Calls from them but whenever I try to use them on a server rendered Page, I keep getting an error. In the tutorials I followed, it worked perfectly fine in the Server Rendered Page so I'm wondering how to fix this.
Related Files:
Here is the Error i get:
You're importing a component that needs useEffect. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.
╭─[@trpc+react-query@10.43.0@tanstack+react-query@4.36.1@trpc+client@10.43.0_@trpc+server@10.4_7lsmxlrq3xi3juoktsh4534bt4\node_modules@trpc\react-query\dist\createHooksInternal-bdff7171.mjs:2:1]
4 │ import { useQuery, useQueryClient, useMutation, hashQueryKey, useInfiniteQuery, useQueries } from '@tanstack/react-query';
5 │ import React, { createContext, useRef, useState, useEffect, useCallback, useMemo } from 'react';
· ─────────
6 │
7 │ /**
8 │ * We treat
undefined
as an input the same as omitting an input
╰────
Maybe one of these should be marked as a client entry with "use client":
./src\app_trpc\client.ts
./src\app\page.tsx2 replies