Next.js Discord

Discord Forum

Re-running gSSP vs refetching on the client side

Unanswered
Siricid woodwasp posted this in #help-forum
Open in Discord
Siricid woodwaspOP
Hi!
Here's a semi high-level description of a case I'm wondering about:

Let's imagine a website with a sidebar and a products component. In the sidebar there's a bunch of filters, clicking which updates the url. That should cause the data to refetch in some way or another, which would in effect cause the products component to update with the new data. Now, for SEO purpose the initial products data is fetched within getServerSideProps (or a page RSC for that matter) based off the url.

The question I have is - how to handle refetching that data dynamically (without using react-query, SWR etc. just for the sake of the question).

Should I be using a <Link> component with shallow={false} to re-run gSSP and refetch the data that way, or should I be using shallow={false} (or router.push with shallow set to true) and handle refetch directly within the event that updates the url (or even useEffect if need be).

Re-running gSSP seems a bit counter intuitive as it may contain many more fetches or functions, while running a single fetch is well.. cheaper, for sure. Then again, having to 'match' many of these fetches also doesn't seem like a great idea.

What's the proper/preferable way of handling that? Preferably both from the perspective of pages and the app router.

Thanks in advance!

1 Reply

Siricid woodwaspOP
bump