#Does a hybrid SSG approach exist that falls back first to SSR, and then to a 404 page?

1 messages · Page 1 of 1 (latest)

velvet merlin
#

Potential use-case: Best selling products in a system where product data can change often at times.

Is it possible to use generateStaticParams for a subset of products whose product pages then get rendered using SSG. If the ID param is not returned by generateStaticParams the server should fall back to SSR and if the product cannot be found route to a 404 page.

Is this possible and/or viable? Or should pages like that simply use SSR and that's it?

@solar willow I saw your answer to another question about generateStaticParams so I hope you don't mind me pinging you here 🙂

tacit sandalBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

dark frost
#

Almost, because for params not returned by generateStaticParams, dynamic rendering only happens for the first render, it will be cached and SSG’d thereafter

velvet merlin
#

Thanks for getting back to me this quickly guys!

Combining both generateStaticParams and dynamicParams would be ISR then?

https://nextjs.org/docs/app/guides/incremental-static-regeneration

This means that after updating a product one would either have to

  • wait for the cache to be invalidated or
  • call revalidatePath for the specific path, e.g. products/1

wouldn't one?

dark frost
velvet merlin
#

Absolutely, thanks for the input, also to you @solar willow, I saw you replied 🙂

tacit sandalBOT