Skip to content

perf(mainweb): prefetch the remaining portal page reads on the server - #584

Merged
aamoghS merged 1 commit into
devfrom
perf/portal-prefetch-rest2
Nov 7, 2026
Merged

aamoghS merged 1 commit into
devfrom
perf/portal-prefetch-rest2

Conversation

@github-actions

@github-actions github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fifteen signed-in portal pages still fetched their first data in the browser after the page loaded, adding one or two round trips before content appeared. This prefetches those reads on the server through PrefetchedPage, as #580 and #582 did for the other pages, so the data ships with the HTML.

  • Pages whose page.tsx was a client component (admin analytics, initiatives, projects, resumes, staff, subteams; scan; club scan; hackathon check-in) are split: the client code moves byte-for-byte to a sibling *Page.tsx, and page.tsx becomes a thin server wrapper.
  • Hackathon detail and /hacklytics prefetch the next-step strip's reads (submission window, my submission, judging itinerary, results) only when nextStepQueries enables them for the user's registration. The shared logic is in lib/next-step-reads.server.ts.
  • The judge desk prefetches its context, then announcements, itinerary and the project queue (with the client's default filters). That removes a two-step waterfall.
  • Admin hackathons prefetches each card's events. The admin hackathon dashboard prefetches the wave status and the registration email status when the Applications tab shows them.
  • Each input matches the client useQuery input, so react-query finds the data in its cache. A read the user isn't allowed to make is skipped, and the client fetches it as before.

Testing

Production builds of dev and this branch were run side by side against the local Docker test database (seeded users), with 100 ms of network latency emulated:

  • 13 of the 15 pages now make zero client tRPC calls after load. Before this change, their data arrived 0.8 to 2.1 s after navigation.
  • The judge desk is left with only its heartbeat mutation.
  • /lead for a non-leader still refetches, because the server read returns FORBIDDEN; a leader gets the data prefetched.
  • Rendered text, html class, final URL and console/hydration errors are identical between the two builds:
    • every page, at widths 402 and 1440, for the hacker, judge, member and admin users;
    • for a non-admin on the admin and scan pages;
    • signed out.
  • typecheck, lint and next build pass.

@github-actions
github-actions Bot requested a review from aamoghS as a code owner November 7, 2026 01:40
@aamoghS aamoghS changed the title Feature: perf/portal-prefetch-rest2 to dev perf(mainweb): prefetch the remaining portal page reads on the server Nov 7, 2026
@aamoghS aamoghS closed this Nov 7, 2026
@aamoghS aamoghS reopened this Nov 7, 2026
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

Visit the preview URL for this PR (updated for commit 5a1db8b):

https://hacklytics2027--pr-584-251a4qcn.web.app

(expires Sat, 14 Nov 2026 01:43:18 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: c48ba34db61581e25fe2978355160b5eefe0e83f

@aamoghS
aamoghS merged commit 79d4dfb into dev Nov 7, 2026
11 checks passed
@aamoghS aamoghS mentioned this pull request Nov 7, 2026
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant