-
Notifications
You must be signed in to change notification settings - Fork 17
feat: move Layout component back to SSR #479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request refactors account-related pages to use Next.js static generation (SSG) instead of client-side data fetching, improving performance and SEO. The changes move data fetching from the client to the server at build time, and optimize component loading by dynamically importing browser-only components with SSR disabled.
Key changes:
- Converted three account pages (
delegating,orchestrating,history) to usegetStaticPathsandgetStaticPropsfor static generation with ISR (revalidation every 600 seconds) - Refactored
AccountLayoutto accept account and orchestrator data as props instead of fetching them internally - Changed the main
Layoutcomponent from dynamic to static import in_app.tsxto ensure it's always server-rendered - Dynamically imported several UI components (
DelegatingView,DelegatingWidget,ConnectButton,Claim,TxConfirmedDialog,RegisterToVote) with SSR disabled to reduce initial bundle size
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| pages/accounts/[account]/orchestrating.tsx | Added SSG with getStaticPaths and getStaticProps to pre-render orchestrator account pages at build time |
| pages/accounts/[account]/history.tsx | Added SSG with getStaticPaths and getStaticProps to pre-render account history pages at build time |
| pages/accounts/[account]/delegating.tsx | Added SSG with getStaticPaths and getStaticProps to pre-render delegator account pages at build time |
| pages/_app.tsx | Changed Layout component from dynamic to static import for consistent SSR |
| layouts/main.tsx | Added dynamic imports with SSR disabled for browser-only components to optimize bundle size |
| layouts/account.tsx | Removed client-side SWR data fetching logic and refactored to accept data as props; added dynamic imports for client-only components |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Getting 500 errors on the preview deployment but it doesn't seem like they are related to the PR, as all of them seem to happen in the API endpoints. |
AI Summary
This pull request refactors the account-related pages (
delegating,orchestrating,history) to use Next.js static generation (getStaticPaths/getStaticProps) for improved performance and SEO, and updates how dynamic components are loaded throughout the layouts. The main changes are the removal of client-side data fetching in favor of server-side/static data fetching and the use of dynamic imports for certain components to optimize bundle size and rendering.Account Pages: Static Generation and Data Fetching
delegating,orchestrating,history) to usegetStaticPathsandgetStaticProps, fetching account and orchestrator data at build time or on-demand, and passing them as props to theAccountLayoutcomponent. This replaces the previous client-side SWR fetching approach. (pages/accounts/[account]/delegating.tsxR3-R69, pages/accounts/[account]/history.tsxR3-R69, pages/accounts/[account]/orchestrating.tsxR3-R69)AccountLayoutcomponent to acceptaccountandsortedOrchestratorsas props instead of fetching them internally, and removed all SWR and client-side data loading/error handling logic. [1] [2]Dynamic Component Loading
layouts/account.tsxandlayouts/main.tsx(such asDelegatingView,DelegatingWidget,ConnectButton,Claim,TxConfirmedDialog,RegisterToVote) with dynamic imports using Next.js'sdynamic()function and disabled server-side rendering for them. This helps reduce the initial JS bundle size and avoids SSR-related issues with browser-only components. [1] [2] [3] [4] [5]App Layout Import Change
Layoutcomponent in_app.tsxfrom a dynamic import to a static import, ensuring layout is always server-rendered for consistency. [1] [2]These changes collectively improve the performance, reliability, and maintainability of the account-related pages by leveraging Next.js's static generation and optimizing component loading.