𝗦𝘁𝗮𝘁𝗶𝗰 𝗦𝗶𝘁𝗲𝘀 𝗪𝗶𝘁𝗵 𝗟𝗶𝘃𝗲 𝗜𝗻𝘃𝗲𝗻𝘁𝗼𝗿𝘆

You want a fast site. You also need accurate stock levels. Most people pick one. They choose speed or accuracy. You do not have to.

Static sites are fast. But data goes old between builds. Client side fetching is accurate. But it adds loading spinners. Spinners kill the user experience.

Use two layers of truth.

Layer one serves external systems.

  • Use build time data for Google and Meta.
  • This stops ads for sold items.
  • A sync script keeps this data fresh.

Layer two serves your visitors.

  • Render the shop grid as static HTML.
  • Assume items are available.
  • Use a small script to patch the UI after the page loads.
  • This removes the buy button for sold items.

This approach removes loading states. The page feels instant. If your API fails, the site still works. Users browse and add to cart. If an item is sold, the cart rejects the request.

A cart error is better than a blank screen.

Use this for low traffic shops. It works for art or niche goods. Do not use this for flash sales. High traffic needs strict checks.

Source: https://dev.to/dbartalos/static-site-live-inventory-two-sources-of-truth-that-dont-fight-each-other-5c0a