Next.js Discord

Discord Forum

Ecommerce, use generateStaticParams() for product pages BUT with dynamic price component

Unanswered
Canaan Dog posted this in #help-forum
Open in Discord
Canaan DogOP
Hi all, I am using NextJS 13.5 to build an ecommerce.

In the app/products/[slug]/page.jsx I have product name, description, price and other product related information. I use the generateStaticParams() function in order to statically build each product page on build time with next build.

Having said all that, the problem I am facing is that a product's price cannot be static. Products' prices change frequently, sometimes even daily.
How could I have the price of every product to be dynamic and fetched from the database on each visit, even though the rest of the product page (name, description etc) is static?

Any knowledge or ideas are appreciated! 🤗 🙏

0 Replies