Skip to content

Optimize product page route shell #1455

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

unstubbable
Copy link

stacked on #1454

Due to the product pages using the ProductProvider, which uses useSearchParams, the product route shells are currently pretty much empty. This PR attempts to sketch out how we could push the useSearchParams further down, and use it more granularly, so that skeletons can be used as suspense fallbacks wherever product selections can be made that influence the search params. Thus allowing us to statically prerender most of the product details into the route shell. The selection elements then become interactive on hydration. There's still some minor CLS that should be fixed, but it's a start.

Copy link

vercel bot commented May 15, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
commerce-shopify ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 15, 2025 1:13pm

@unstubbable
Copy link
Author

unstubbable commented May 15, 2025

I fell into a trap here. Because of the absence of generateStaticParams, Next.js is considering this route as high-cardinality, and will always use the fallback shell for all routes. It won't produce route shells on-demand when visiting the product pages with specific params. What tripped me up was that with next start we currently do generate those route shells. That needs to be fixed in Next.js.

However, this approach is still valid if we decide to use generateStaticParams to prerender all or some product pages (e.g. for the most popular products).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant