Skip to content

feat: migrate GitHub stars fetch to TanStack Query#1213

Closed
mvanhorn wants to merge 1 commit intoMODSetter:mainfrom
mvanhorn:feat/1198-tanstack-query-github-stars
Closed

feat: migrate GitHub stars fetch to TanStack Query#1213
mvanhorn wants to merge 1 commit intoMODSetter:mainfrom
mvanhorn:feat/1198-tanstack-query-github-stars

Conversation

@mvanhorn
Copy link
Copy Markdown
Contributor

@mvanhorn mvanhorn commented Apr 10, 2026

Replaces the manual useEffect + fetch pattern in NavbarGitHubStars with useQuery from @tanstack/react-query, matching how the rest of the codebase handles data fetching.

What changed:

  • github-stars-badge.tsx: Replaced useState + useEffect + manual AbortController with a single useQuery call. The abort signal is provided by TanStack Query automatically. Added a 5-minute staleTime so the star count isn't re-fetched on every navigation.
  • cache-keys.ts: Added github.repoStars cache key for the query.

Note: The useLatestRelease hook in hero-section.tsx mentioned in #1198 has already been removed from the codebase, so only the stars badge needed migration.

Closes #1198

High-level PR Summary

This PR migrates the GitHub stars fetching logic from a manual useEffect and fetch pattern to TanStack Query's useQuery hook, aligning with the codebase's standard data fetching approach. The change introduces a cache key for the GitHub stars query and adds a 5-minute staleTime to reduce unnecessary API calls during navigation. The migration simplifies the component by removing manual state management and AbortController handling, which TanStack Query provides automatically.

⏱️ Estimated Review Time: 5-15 minutes

💡 Review Order Suggestion
Order File Path
1 surfsense_web/lib/query-client/cache-keys.ts
2 surfsense_web/components/homepage/github-stars-badge.tsx

Need help? Join our Discord

Analyze latest changes

Replace the manual useEffect + fetch in NavbarGitHubStars with
useQuery from @tanstack/react-query. This gives the component
caching, request deduplication, automatic retries, and devtools
visibility for free.

The useLatestRelease hook referenced in the issue has already been
removed from hero-section.tsx, so only the stars badge needed
migration.

Closes MODSetter#1198
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 10, 2026

@mvanhorn is attempting to deploy a commit to the Rohan Verma's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown

@recurseml recurseml bot left a comment

Choose a reason for hiding this comment

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

Review by RecurseML

🔍 Review performed on 7c61668..9cfaa72

✨ No bugs found, your code is sparkling clean

✅ Files analyzed, no issues (2)

surfsense_web/components/homepage/github-stars-badge.tsx
surfsense_web/lib/query-client/cache-keys.ts

@MODSetter
Copy link
Copy Markdown
Owner

@mvanhorn Please raise PR's on dev branch

@mvanhorn
Copy link
Copy Markdown
Contributor Author

Apologies for the wrong branch, re-submitted against dev in #1215. I'll default to dev for future PRs to this repo.

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.

Migrate homepage GitHub API fetches from useEffect to TanStack Query

2 participants