vercel / commerce

Next.js Commerce

Home Page:https://demo.vercel.store

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cost marking all components edge rundtime?

osseonews opened this issue · comments

We have forked this repo and added many features for our Shopify store, and were planning on launching it soon. However, we were concerned as every Server component here for every App Router page is marked as: export const runtime = 'edge';.

Does this mean that every page will count as an edge runtime invocation? If so, as Vercel limits Edge invoccations wouldn't that quickly rack up substantial costs on any website with a decent amount of traffic even on the Pro plan? I mean every time any person or bot (which cause the most traffic) visits the site and calls a product page, there will be Edge invocations. If you have let's say 1,000 products and get 1,000 visits a day, that's 1 million edge invocations a day! Is this accurate or I am misunderstanding what an edge invocation is, so 1,000 products is only one invocation because the Page is the same code for each product?

We are moving away from the Edge Runtime here -> #1236

Server Components don't have to run dynamically, they can instead by rendered statically during the build. If you do not want any dynamic parts of your application that require running compute at runtime, you can remove that functionality from the template. For example, we use dynamic rendering here to read cookies and understand what is saved in the user's cart.

So basically any route that requires some dynamic functionality, like the cart, should be marked as runtime=edge, and everything else can just be static? I'm also confused, in your pull request, you remove the Suspense around Related Products, in app/product/[handle]. But, you are doing a data fetch request in the Related Products component, so why is suspense removed?