Data Ownership & Codebase maintenance issue in the new App Router Paradigm #77629
Unanswered
asde29873012549
asked this question in
App Router
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
🧠 Data Ownership & Codebase Maintenance in the New App Router Paradigm
With the new App Router paradigm in Next.js, we’re entering a world that radically changes how we build and reason about our applications—from component composition to data fetching and rendering flow.
According to the Next.js documentation, data should primarily be fetched in React Server Components (RSC) to take advantage of server-side rendering, reduced JavaScript bundle size, streaming, and better performance. That said, the docs also clearly acknowledge that client-side data fetching (e.g., using
react-query
orswr
) still has a place—especially when dealing with interactivity, mutations, or real-time updates.This raises a pretty fundamental question:
Is this a real problem? Or are we just not thinking modularly enough yet?
🧪 For Example
Let’s say this week, you build a navigation bar filled with clothing categories like "shorts", "trousers", etc. Since these categories are relatively static and rarely change, you implement it as a React Server Component using a native
fetch
.Fast forward three weeks—you're now asked to build a page that allows admins to create or update those same categories. Since this new page requires user interaction, you implement it as a Client Component and use TanStack Query (
react-query
) for fetching and mutations.Everything works fine—until a user updates a category and notices that the nav bar doesn’t reflect the changes. Why? Because it’s still using the server-rendered, cached data from the RSC. Unless you remember to call
router.refresh()
(and even then, only if caching is disabled or revalidated correctly), the nav bar stays stale.This creates an out-of-sync UI, even though both components are technically fetching the "same" data.
The TanStack Query docs actually warn about this pattern:
🧩 So What Do We Do?
On one hand, this new data-fetching flexibility is powerful.
On the other, the cognitive overhead and potential for state fragmentation seem very real—especially as your app grows and more devs work on it.
So I’m curious:
Would love to hear how others are thinking about data ownership, mutations, and avoiding inconsistencies in the App Router world 👇
Beta Was this translation helpful? Give feedback.
All reactions