(shallow routing) Updating search params causes server component to rerun. #49540
-
I have a page that fetches initial data like: export default async function PaymentPage() {
const data = await fetchOrderData();
return <PaymentFlow order={data} />
} Now the problem is that when I update search params in URL to include something like step of current payment flow: router.push('/payment-page?step=1') It causes the Any way this can be fixed? In previous versions of nextjs I could use shallow routing, but it's not possible now. "next": "13.4.1", related discussion #48110 |
Beta Was this translation helpful? Give feedback.
Replies: 10 comments 4 replies
-
I noticed that the server code rerun only if I visit the URL for the first time:
|
Beta Was this translation helpful? Give feedback.
-
Hey! I have the same issue. I want to keep form state in URL. But URL update triggers a page reloading. |
Beta Was this translation helpful? Give feedback.
-
Got the same issue |
Beta Was this translation helpful? Give feedback.
-
Same Issue |
Beta Was this translation helpful? Give feedback.
-
Having to wait for all data to be fetched before the url changes is a bad user experience. |
Beta Was this translation helpful? Give feedback.
-
same issue, a router.replace/push(xyz, {shallow:true}) would be great. I've heard there's already some code for that... ;-) |
Beta Was this translation helpful? Give feedback.
-
any update on this ? Do we have a clear answer here ? |
Beta Was this translation helpful? Give feedback.
-
I think I have a similar issue. I have two different areas in a page that are affected by different searchParams. Button A change the searchParam A that is filtering Area A. I have a Suspense over Area A with searchParam A as a key. If I click Button A, the page wil only respond when Area B ends its async processment. The solution to get the page respond instantly (showing the Suspense fallback of the affected area) is to add both searchParams as the keys of both Suspense, but this will make both areas to load again even if their filter weren't changed. Can we make a page to answer instantly if the Suspense keys on it doesn't change? Or at least add some kind of configuration to the Suspense in order to make it behave like that? |
Beta Was this translation helpful? Give feedback.
-
Yes it has a very unexpected behavior, in DEV it works fine for me, but in PROD push will rerender the whole page and lose state. |
Beta Was this translation helpful? Give feedback.
-
This has been solved for a while but apparently there were multiple issues/discussions asking for the same thing. Here's the docs: https://nextjs.org/docs/app/building-your-application/routing/linking-and-navigating#using-the-native-history-api. |
Beta Was this translation helpful? Give feedback.
This has been solved for a while but apparently there were multiple issues/discussions asking for the same thing. Here's the docs: https://nextjs.org/docs/app/building-your-application/routing/linking-and-navigating#using-the-native-history-api.