Repository navigation
feat(ssr): server-render landing rows and first page of builders (fixes #410) - #429
Conversation
|
@lmduy2612 is attempting to deploy a commit to the Threadflow Team on Vercel. A member of the Team first needs to authorize it. |
|
@lmduy2612 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
Thanks @lmduy2612 , this works well. Two changes before merge: Add a timeout to the server-side fetches (for example signal: AbortSignal.timeout(5000) in the init you pass). Without it, a hanging API hangs the whole page instead of falling back to the client states. Small cleanups: use the imported helpers directly instead of the const readFilters = ... aliases. |
- Add AbortSignal.timeout(5000) to server-side prefetches in page.tsx and builders/page.tsx - Remove custom shouldDehydrateQuery to only dehydrate successful queries by default - Replace helper aliases with direct imports in builders-view.tsx
|
Thanks for the review @0xdevcollins! Updated in
Verified locally with |
|
Hi @0xdevcollins, gentle reminder as Wave 10 is ending tomorrow (Oct 22). All requested updates (AbortSignal timeout, default query hydration, and alias cleanup) have been completed and verified. Whenever you have a moment, could you please take a look and merge? Thank you! |
Conflicts resolved: - stats-strip.tsx: keep the shared STATS/fetchTotal from landing-queries.ts. Main (boundlessfi#433) dropped the Teams stat, so drop it from landing-queries.ts too (and PublicOrganizationListDto from CountedList); otherwise the move would have brought Teams back and prefetched /organizations on the server. - featured-projects.tsx: keep the shared featured query, import toProjectCard from its new home next to it (boundlessfi#432) and keep mainAppUrl for "Browse all projects". - builders-view.tsx: keep the shared URL parsing from use-builders.ts and the "How to get listed" hook-up from boundlessfi#428, in the file's current quote style.
Summary
Server-renders the first view of the landing rows (
/) and the directory (/builders) using TanStack Query v5HydrationBoundaryanddehydrate, prefetching data on the server with appropriate cache revalidation windows before handing off to the client query hooks.Fixes #410
Changes Made
Landing Page (
/):/users/directory?limit=1,/projects?limit=1,/organizations?limit=1), Top builders (/users/top-builders?limit=8), and Featured projects (/projects/featured).next: { revalidate: 180 }(3 minutes) cache window on server fetches to protect the API from repeated visits.<StatsStrip />,<TopBuilders />, and<FeaturedProjects />in<HydrationBoundary state={dehydrate(queryClient)}>.Builders Directory (
/builders):parseBuildersQueryParams— sharing the exact same URL-parsing and defaulting logic as the client directory (readBuilderFilters,readBuilderPage,readBuilderSort).buildersKeys.list(queryParams)) and filter facets (buildersKeys.filters) usingnext: { revalidate: 60 }(1 minute cache window).<HydrationBoundary>so the first page renders directly in the server HTML while preserving client-side filtering, sorting, pagination, and debounce without full reloads.Resilience:
Promise.allSettledand dehydrate errors safely, ensuring that if the API is down or unreachable, the pages still render and display existing client error/fallback states rather than failing with HTTP 500.View-source Verification Snippets
1. Landing Page (
/): Top builders rendered directly in server HTML2. Directory Page (
/builders): First page of builders rendered in server HTML3. Filtered Directory Page (
/builders?skills=UX%20Design): Filtered builders in server HTMLVerification Checklist
npm run lintpasses (0 errors, 0 warnings)npx tsc --noEmitpasses (0 errors)npm run buildpasses (Next.js 16 Turbopack production build)npm run seo:checkpasses (all HTML & XML routes 200 and SEO tags present)//builders?skills=...