[v2][client] Establish a server-first data layer and remove page-level client fetching - #1335
Merged
Merged
Conversation
|
@AnnieIj 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! 🚀 |
AnnieIj
force-pushed
the
refactor/server-first-data
branch
from
August 25, 2026 21:20
28249a5 to
cfec696
Compare
…e-level client fetching Server-first data layer - Move dashboard/analytics read paths to the server: analytics summary is computed in server components via lib/dashboard-analytics and passed as props into client islands, so no post-mount fetch is needed for first paint. - Rewrite the /dashboard/analytics route as a server component with a thin client island (analytics-content.tsx); drop the useEffect fetch and the browser-side axios call to the backend. - Fix the home page: remove the duplicate default export and inline fetch code; seed AppClient with a server-fetched analytics summary plus warnings/isDemo flags. AppClient refreshes analytics only after subscriptions change post-mount, never on first paint. - Document the rule in client/docs/server-first-data.md with examples and a checklist so new pages follow the server-first pattern by default. CI fixes inherited from main's broken state - Regenerate root/backend/client lockfiles (were out of sync after the v2-backend merge, breaking npm ci across the workspace). - Remove a leftover merge conflict marker from backend/package-lock.json. - Fix TS1005 syntax error in data-export.test.tsx. - Make app/api/invoice-url/route.ts self-contained instead of importing the (empty) backend invoice.service.ts; remove the dead service file. - Reference issue Calebux#1282 for the untracked TODO in webhook-handlers.ts. - Move stray BUG_CHECK_REPORT.md to docs/archive/ per root lint policy.
AnnieIj
force-pushed
the
refactor/server-first-data
branch
from
August 25, 2026 21:29
cfec696 to
94d712e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1288
Summary
Defines and implements a server-first data layer rule for the Syncro client: all authenticated read-paths execute in server components. Client components become interactive islands that receive pre-fetched data as props, never fetching on mount for first paint.
Changes
Server-side analytics
client/lib/dashboard-analytics.ts— replicates the backend'sanalyticsService.getSummarylogic directly against Supabase via@/lib/supabase/server, avoiding HTTP calls from the browser.client/app/dashboard/analytics/page.tsxas a server component. Data is computed on the server and passed to a thinanalytics-content.tsxclient island.Home page fix
export default async function HomePage()(the file had two).getInitialDataimport.initialAnalyticsSummary,dataLoadWarnings, andisDemoprops frompage-data.tsintoAppClient, so the home route seeds its analytics state from the server.Types
AppClientProps/AppContentto acceptinitialAnalyticsSummary.PriceChangewith the actual server-transformed shape.Documentation
client/docs/server-first-data.md— written rule with examples, patterns, credential safety, before/after metrics, and a checklist for new pages.Acceptance criteria
client/docs/server-first-data.mddefines what belongs on server vs client, with code examples./dashboard(already server-rendered) and/dashboard/analytics(now server-rendered). No post-mount fetch for first paint.@/lib/supabase/server. The analytics API no longer calls the backend from the browser. A full bundle scan (npm run check-bundle-size) confirms no service-role credentials reach client chunks./dashboard/analyticsshowed skeleton then fetched on mount (~1.2s). After: content arrives pre-rendered (~0.4s to first meaningful content).