-
Notifications
You must be signed in to change notification settings - Fork 24
[feat]: Server-Side Rendering implementation #924
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
base: main
Are you sure you want to change the base?
Conversation
…meddelande som sammanfattar ändringarna: ``` feat: lägg till server-side rendering (SSR) med Vite ``` Några viktiga saker att tänka på: 1. Se till att du har installerat alla nödvändiga dependencies: ```bash npm install express react-dom/server react-router-dom/server npm install -D @types/express ``` 2. Uppdatera `.gitignore` för att exkludera SSR-relaterade build-mappar: ``` dist/ dist-ssr/ ``` 3. Kontrollera att dina befintliga komponenter och routes fungerar med både client-side och server-side rendering. 4. Testa SSR genom att köra: ```bash npm run dev ``` Några potentiella utmaningar du kan stöta på: - Hantering av asynkrona data-fetching - Routing med StaticRouter - Hydration av komponenter Vill du att jag ska hjälpa dig att felsöka eller optimera SSR-implementationen ytterligare? Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <[email protected]>
Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <[email protected]>
Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <[email protected]>
Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <[email protected]>
Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <[email protected]>
Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <[email protected]>
Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <[email protected]>
Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <[email protected]>
Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <[email protected]>
Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <[email protected]>
Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <[email protected]>
Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <[email protected]>
Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <[email protected]>
Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <[email protected]>
Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <[email protected]>
Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <[email protected]>
…ring Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <[email protected]>
Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <[email protected]>
Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <[email protected]>
Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <[email protected]>
Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <[email protected]>
Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <[email protected]>
Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <[email protected]>
refactor: justera manuella chunks för att stödja SSR-bygge Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <[email protected]>
feat: förbättra metadata och SEO för webbplatsen Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <[email protected]>
Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <[email protected]>
Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <[email protected]>
Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <[email protected]>
Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <[email protected]>
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 PR implements Server-Side Rendering (SSR) for the Klimatkollen frontend to improve initial page load performance and SEO. The implementation includes a complete migration from client-only rendering to SSR with Express.js, hydration support, and proper error handling.
Key changes:
- Added SSR infrastructure with Express.js server and dual entry points (client/server)
- Converted to lazy loading for all pages except LandingPage to optimize bundle size
- Fixed hydration mismatches by adding proper client-side checks for browser-only APIs
- Updated routing to explicit language-prefixed paths instead of dynamic routing
Reviewed Changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 5 comments.
Show a summary per file
File | Description |
---|---|
vite.config.ts | Added SSR configuration, external dependencies, and build optimizations |
src/routes.tsx | Converted to lazy loading and explicit language-prefixed routes |
src/entry-server.tsx | New SSR entry point for server-side rendering |
src/entry-client.tsx | New client entry point with hydration support |
src/main.tsx | Converted to compatibility stub |
server.js | Express.js SSR server with error handling and fallback |
package.json | Updated build scripts and added Express dependency |
Dockerfile | Migrated from nginx to Node.js production setup |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
…nd SEO content (excluding translations)
I removed the previous PageSEO and replaced with the newPageSEO previously created for this PR. Updated all previous uses and started expanding SEO content (not all translations are set up with the current commit) |
✨ What's Changed?
This PR implements Server-Side Rendering (SSR) for the Klimatkollen frontend,
significantly improving initial page load performance and SEO. The changes include:
• SSR Implementation: Added complete server-side rendering with Express.js server
• Hydration Fixes: Resolved hydration mismatches between server and client rendering
• Route Updates: Updated wildcard route syntax to use named parameters (*catchAll)
• Performance Optimizations: Added proper CSS loading and font-display optimizations
• Error Handling: Improved SSR error handling with graceful fallback to client-side
rendering
Key technical improvements:
• Eliminated white flash during page loads by ensuring CSS is available during SSR
• Fixed localStorage access issues during server-side rendering
• Added proper Helmet integration for dynamic meta tags and titles
• Implemented language redirection for non-prefixed insight routes
📸 Screenshots (if applicable)
📋 Checklist
• [x] PR title starts with [feat]: Server-Side Rendering implementation
• [x] I've verified the change runs locally
• [x] I've set the labels, issue, and milestone for the PR
• [x] I've created sub-tasks or follow-up issues as needed
🛠 Related Issue
None yet