unable to setup RQ in next.js project
this is my code,
and I am getting an error that

11 Replies
harsh-harlequinOP•13mo ago
adverse-sapphire•13mo ago
Follow this section for how you should setup RQ in a Next App Router project.
https://tanstack.com/query/latest/docs/framework/react/guides/advanced-ssr
Advanced Server Rendering | TanStack Query React Docs
Welcome to the Advanced Server Rendering guide, where you will learn all about using React Query with streaming, Server Components and the Next.js app router.
You might want to read the Server Rendering & Hydration guide before this one as it teaches the basics for using React Query with SSR, and Performance & Request Waterfalls as well as Pre...
eastern-cyan•13mo ago
Follow this sectionnot really. you put the
QueryClientProvider
into the root layout, which is a server component. But it needs to go into its own client component (that can take server components as children). That's why we have a <Providers>
component explicitly in the docs.
also you are creating the QueryClient wrong - this is now how we do it in the docsadverse-sapphire•13mo ago
Yeah, that's what the doc explains too
eastern-cyan•13mo ago
I don't understand. The code you're showing and the code example in the docs isn't the same
so I think you're doing it wrong
adverse-sapphire•13mo ago
Im just trying to help him, code isn't mine, I referred him to that doc page on how the setup should look like
eastern-cyan•13mo ago
sorry, I misread 🙈
adverse-sapphire•13mo ago
I figured hahaha
harsh-harlequinOP•13mo ago
thanks, now it's working
do I have to use the
'use client'
directive every time I am fetching or if mutating data using RQ?
thanks for helping me outadverse-sapphire•13mo ago
useQuery & useMutation are hooks which means you need to use the 'use client' directives
harsh-harlequinOP•13mo ago
Okay, thanks for this info