What is the recommended way to serve documents from Firestore in a Next.js app? #13310
-
Hey, I'm building an ecommerce like website using Next.js and Firebase, however I have a question for someone with more experience in Next.js, as I'm just starting out. When serving a product (ie: product details page) should I:
What is the best practice for this use case? Or is there a better way to do it? I'm mainly concerned about SEO and speed of course. Many thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Are you deploying with Vercel? If so, I'd recommend using
This will be the best approach for SEO and performance. |
Beta Was this translation helpful? Give feedback.
Are you deploying with Vercel? If so, I'd recommend using
getStaticPaths
/getStaticProps
in combination with Incremental Static Regeneration. Here's how this would work:/pages/products/[name].js
.getStaticPaths
would fetch all the product IDs or names to generate all of the routes.getStaticProps
would fetch the single product snapshot from Firestore.fallback: true
andunstable_revalidate
, you can periodically regenerate the static pages, ensuring there's zero downtime for your products (very important for e-commerce).This will be the best approach for SEO and performance.