Skip to content

Parallelize SSR fetches on the home page#2416

Merged
Simek merged 1 commit intoreact-native-community:mainfrom
azizbecha:fix/parallelize-home-ssr-fetches
Apr 29, 2026
Merged

Parallelize SSR fetches on the home page#2416
Simek merged 1 commit intoreact-native-community:mainfrom
azizbecha:fix/parallelize-home-ssr-fetches

Conversation

@azizbecha
Copy link
Copy Markdown
Contributor

Summary

  • pages/index.tsx was awaiting five ssrFetch calls one after another inside getServerSideProps, then awaiting each .json() sequentially. The fetches don't depend on each other.
  • Fan them out with Promise.all for both the requests and the JSON parses, so the waterfall collapses into a single roundtrip's worth of latency on the home page.

Test plan

  • bunx oxlint pages/index.tsx — clean
  • bunx oxfmt --check pages/index.tsx — clean
  • bun start and load / locally; dev-server log shows the five /api/libraries... requests issued in the same window (~470ms each, overlapping) instead of stacked sequentially. Warm renders return in ~24-185ms with all five API calls completing in ~5-15ms each, in parallel. No runtime errors.

The home page was awaiting five ssrFetch calls sequentially in
getServerSideProps, then awaiting each .json() one at a time.
Fan them out with Promise.all so the waterfall collapses into a
single roundtrip's worth of latency.
Copy link
Copy Markdown
Member

@Simek Simek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @azizbecha, thanks nice catch and improvement! 👌

We already use parallel promises for package pages fetches, but I have missed this on the home page.

Would you be interested in optimizing also the Popular page fetches? Can be done in a separate PR.

@Simek Simek merged commit 571f176 into react-native-community:main Apr 29, 2026
1 check passed
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.

2 participants