Your e-commerce Next.js application needs to display real-time inventory data on product pages. Which data-fetching method would be most appropriate?

  • Use client-side rendering (CSR) with WebSockets to maintain a live connection for real-time updates.
  • Use server-side rendering (SSR) with a caching layer to minimize data requests and optimize performance.
  • Use server-side rendering (SSR) with data fetching at runtime on the client side to ensure real-time updates.
  • Use static site generation (SSG) with periodic revalidation to update inventory data at predefined intervals.
To display real-time inventory data on product pages in a Next.js e-commerce application, it's most appropriate to use server-side rendering (SSR) with data fetching at runtime on the client side. This allows you to ensure real-time updates while maintaining the benefits of server-side rendering. SSG with periodic revalidation is better for static data that doesn't change frequently. CSR with WebSockets introduces complexity and may not be as SEO-friendly. Using SSR with caching can improve performance but may not provide real-time updates.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *