Skip to content

Server-Side Rendering#76

Merged
kostya-zero merged 22 commits into
mainfrom
feature/ssr
Sep 30, 2025
Merged

Server-Side Rendering#76
kostya-zero merged 22 commits into
mainfrom
feature/ssr

Conversation

@kostya-zero
Copy link
Copy Markdown
Member

@kostya-zero kostya-zero commented Sep 28, 2025

В общем

Реализован SSR для всех возможных страниц. Чтобы не отдавать на рендер всю страницу клиенту, я сделал так, что большая часть страницы рендерится на сервере, и уже динамический контент рендерится на клиенте.

Сравнение Size и First Load JS

Старый

Route (app)                                 Size  First Load JS
┌ ○ /                                    5.52 kB         187 kB
├ ○ /_not-found                            139 B         103 kB
├ ○ /auth                                3.79 kB         117 kB
├ ○ /clubs                               8.65 kB         209 kB
├ ƒ /clubs/[id]                          6.94 kB         244 kB
├ ƒ /clubs/[id]/subscribers              4.61 kB         199 kB
├ ƒ /events                              3.78 kB         127 kB
├ ƒ /events/[id]                         3.08 kB         153 kB
├ ○ /events/calendar                     17.8 kB         215 kB
├ ○ /finder                                139 B         103 kB
├ ƒ /post/comments/[id]                  19.2 kB         287 kB
├ ○ /post/draft                          3.58 kB         119 kB
├ ○ /profile                             6.96 kB         207 kB
├ ƒ /profile/[id]                        5.36 kB         236 kB
├ ƒ /profile/[id]/clubs                  5.32 kB         205 kB
├ ○ /profile/clubs                       5.43 kB         205 kB
├ ƒ /profile/settings                    7.91 kB         206 kB
├ ○ /profile/settings/about              2.99 kB         127 kB
├ ○ /profile/settings/appearance         3.77 kB         130 kB
├ ƒ /profile/settings/club/[id]          9.54 kB         204 kB
├ ○ /profile/settings/create-club        10.3 kB         221 kB
├ ○ /profile/settings/edit               1.24 kB         117 kB
├ ○ /profile/settings/feedback           1.24 kB         117 kB
└ ○ /profile/settings/notifications      1.24 kB         117 kB
+ First Load JS shared by all             103 kB
  ├ chunks/1255-84120358be6b2e7f.js      45.5 kB
  ├ chunks/4bd1b696-100b9d70ed4e49c1.js  54.2 kB
  └ other shared chunks (total)          3.28 kB


ƒ Middleware                             66.5 kB

Новый

┌ ○ /                                       5 kB         186 kB
├ ○ /_not-found                            136 B         103 kB
├ ○ /auth                                 3.8 kB         116 kB
├ ○ /clubs                               11.6 kB         206 kB
├ ƒ /clubs/[id]                          18.7 kB         267 kB
├ ƒ /clubs/[id]/subscribers              4.95 kB         198 kB
├ ƒ /events                              2.73 kB         122 kB
├ ƒ /events/[id]                          1.8 kB         155 kB
├ ○ /events/calendar                     18.1 kB         208 kB
├ ○ /finder                                136 B         103 kB
├ ƒ /post/comments/[id]                  8.04 kB         284 kB
├ ○ /post/draft                           3.5 kB         118 kB
├ ƒ /profile                               136 B         103 kB
├ ƒ /profile/[id]                        3.96 kB         225 kB
├ ƒ /profile/[id]/clubs                  8.55 kB         207 kB
├ ○ /profile/settings                    7.84 kB         201 kB
├ ○ /profile/settings/about              1.73 kB         125 kB
├ ○ /profile/settings/appearance         4.06 kB         129 kB
├ ƒ /profile/settings/club/[id]          5.55 kB         203 kB
├ ○ /profile/settings/create-club        10.6 kB         217 kB
├ ○ /profile/settings/edit               1.16 kB         116 kB
├ ○ /profile/settings/feedback           1.16 kB         116 kB
└ ○ /profile/settings/notifications      1.16 kB         116 kB
+ First Load JS shared by all             103 kB
  ├ chunks/1255-84120358be6b2e7f.js      45.5 kB
  ├ chunks/4bd1b696-100b9d70ed4e49c1.js  54.2 kB
  └ other shared chunks (total)          3.25 kB


ƒ Middleware                             65.1 kB

Оптимизация шрифтов в Next.js работает так, что при сборке он качает их себе локально. В проде, когда юзер открывает страницу, шрифты будут отправляться юзеру напрямую, без надобности отправлять запрос в Google Fonts.

До этого коммита у нас получилось так, что юзер запрашивал шрифты И у нашего сайта И у Google Fonts.
@kostya-zero kostya-zero marked this pull request as ready for review September 29, 2025 17:56
Copy link
Copy Markdown
Contributor

Copilot AI left a 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 all possible pages in the application. The key objective is to reduce client-side rendering load by having the server handle most of the page rendering, leaving only dynamic content to be rendered on the client.

  • Migrated multiple pages to SSR with proper data fetching at the server level
  • Refactored profile routing to use dynamic IDs instead of client-side redirects
  • Removed client-side dependency patterns and replaced with server actions
  • Updated CSS variables and styling optimizations

Reviewed Changes

Copilot reviewed 73 out of 77 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/server-actions/actions/getPersonIdFromToken.action.ts New server action to extract person ID from JWT token
src/server-actions/middleware/utils/jwt-verify.ts Simplified JWT verification by removing explicit type annotation
src/app/(auth)/(withMenuNavigation)/profile/page.tsx Changed to redirect to user-specific profile URL using server-side token parsing
src/app/(auth)/(withMenuNavigation)/events/page.tsx Converted to SSR with server-side data fetching
src/app/(auth)/(withMenuNavigation)/clubs/[id]/page.tsx Added SSR support with proper error handling
Multiple component files Reorganized imports and removed client-side dependencies for SSR compatibility

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/server-actions/middleware/utils/jwt-verify.ts
Comment thread src/components/PostCard/PostCard.tsx
Comment thread src/components/ClubComponents/SubscribeButtons/SubscribeButton.tsx
Comment thread package.json
Comment thread src/app/(auth)/(withMenuNavigation)/profile/[id]/page.tsx
Comment thread src/app/(auth)/(withMenuNavigation)/clubs/[id]/page.tsx
const ClubReportDialogDynamic = dynamic(() => import('@/components/ClubComponents/ClubReportDialog'), {
ssr: false,
});
const ClubReportDialogDynamic = dynamic(() => import('@/components/ClubComponents/ClubReportDialog'));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Тут вроде без ssr: false возникает ошибка в консоли

Copy link
Copy Markdown
Member Author

@kostya-zero kostya-zero Sep 30, 2025

Choose a reason for hiding this comment

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

И вместе с ней тоже, так как это серверный компонент, но без него сборка проходит. Предлагаю пока оставить как есть и посмотреть как это в проде будет работать.

@kostya-zero kostya-zero merged commit e1e88a6 into main Sep 30, 2025
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.

3 participants