T3Stack 'react-query' not found

Hey, I'm trying to migrate to t3 stack, but I've been using react-query, but I am getting this error:
./node_modules/@trpc/next/dist/trpc-next.esm.js:8:0
Module not found: Can't resolve 'react-query'
./node_modules/@trpc/next/dist/trpc-next.esm.js:8:0
Module not found: Can't resolve 'react-query'
// pages/_app.tsx

function MyApp({ Component, pageProps }: AppProps) {
const [queryClient] = useState(() => new QueryClient());

return (
<QueryClientProvider client={queryClient}>
<Component {...pageProps} />
</QueryClientProvider>
);
}

export default withTRPC<AppRouter>({
config({ ctx }) {
const url = `${getBaseUrl()}/api/trpc`;

return {
links: [
loggerLink({
enabled: (opts) =>
process.env.NODE_ENV === 'development' ||
(opts.direction === 'down' && opts.result instanceof Error)
}),
httpBatchLink({ url })
],
url,
transformer: superjson,
queryClientConfig: { defaultOptions: { queries: { staleTime: 60 } } }
};
},

ssr: false
})(MyApp);
// pages/_app.tsx

function MyApp({ Component, pageProps }: AppProps) {
const [queryClient] = useState(() => new QueryClient());

return (
<QueryClientProvider client={queryClient}>
<Component {...pageProps} />
</QueryClientProvider>
);
}

export default withTRPC<AppRouter>({
config({ ctx }) {
const url = `${getBaseUrl()}/api/trpc`;

return {
links: [
loggerLink({
enabled: (opts) =>
process.env.NODE_ENV === 'development' ||
(opts.direction === 'down' && opts.result instanceof Error)
}),
httpBatchLink({ url })
],
url,
transformer: superjson,
queryClientConfig: { defaultOptions: { queries: { staleTime: 60 } } }
};
},

ssr: false
})(MyApp);
30 Replies
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
cje
cje3y ago
what trpc version are you on v10 needs @tanstack/react-query v9 needs react-query
venus
venusOP3y ago
should be the latest one
venus
venusOP3y ago
venus
venusOP3y ago
"@tanstack/react-query": "^4.3.9",
cje
cje3y ago
trpc v9 isnt compatible with tanstack query v4 it needs react-query v3
venus
venusOP3y ago
Owh
cje
cje3y ago
or you can upgrade your trpc stuff to v10 beta
venus
venusOP3y ago
Okay, Imma go with beta, thanks Should I take a look at npx create-t3-app@beta or is it fine just by upgrading packages?
cje
cje3y ago
basically all the boilerplate is different for trpc v10 id do create-t3-app@next beware we have a dependency issue right now, you need to downgrade next-auth to 4.10 before installing packages
venus
venusOP3y ago
Sure, okay. Thanks for letting me know Emm, I've installed @next one, but still getting the react-query dependency error. So do I have to install the old react query?
cje
cje3y ago
youre getting an error about react-query dependencies on just the default output of npx create-t3-app@next?
venus
venusOP3y ago
correct
"@prisma/client": "^4.3.1",
"@tanstack/react-query": "^4.3.9",
"@trpc/client": "^9.27.2",
"@trpc/next": "^9.27.2",
"@trpc/react": "^9.27.2",
"@trpc/server": "^9.27.2",
"next-auth": "4.10.0",
"@prisma/client": "^4.3.1",
"@tanstack/react-query": "^4.3.9",
"@trpc/client": "^9.27.2",
"@trpc/next": "^9.27.2",
"@trpc/react": "^9.27.2",
"@trpc/server": "^9.27.2",
"next-auth": "4.10.0",
cje
cje3y ago
what line of what file?
venus
venusOP3y ago
cje
cje3y ago
trpc-next.cjs.dev is a file from trpc v9 reinstall your dependencies
venus
venusOP3y ago
pretty weird, cuz it is still happening Maybe I missed something to copy from boilerplate I've tried the same create-t3-app@next just by replacing react-query with @tanstack/react-query and then upgrading all packages, then it threw me same error. (disclaimer: I didn't use next-auth)
cje
cje3y ago
eplacing react-query with @tanstack/react-query
what does this mean?
venus
venusOP3y ago
replacing, typo* oh just uninstalling react-query and installing @tanstack/react-query
cje
cje3y ago
there is no react-query to uninstall in a ct3a@next
venus
venusOP3y ago
there is no predefined package there?
cje
cje3y ago
ct3a@next comes with @tanstack/react-query
venus
venusOP3y ago
oh I see now it's installed the correct version of @next, maybe I did something wrong in the terminal before @cje one more question that I ran into during the migration... how's the caching handled in trpc? On normal API endpoint routes I used res.setHeader('Cache-Control', ...). What I can use now?
cje
cje3y ago
Look at what’s inside of ctx
venus
venusOP3y ago
Did I miss something to set up? Currently it provides me only the prisma client.
(parameter) ctx: {
prisma: PrismaClient<Prisma.PrismaClientOptions, never, Prisma.RejectOnNotFound | Prisma.RejectPerOperation | undefined>;
}
(parameter) ctx: {
prisma: PrismaClient<Prisma.PrismaClientOptions, never, Prisma.RejectOnNotFound | Prisma.RejectPerOperation | undefined>;
}
cje
cje3y ago
oh my bad looks like the template currently doesn't do it for you try this
cje
cje3y ago
cje
cje3y ago
Response Caching | tRPC
The below examples uses Vercel's edge caching to serve data to your users as fast as possible.
cje
cje3y ago
probably better to do that than what i said
venus
venusOP3y ago
yep, thanks 🙂
Want results from more Discord servers?
Add your server