@wazir-dev/cli 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (629) hide show
  1. package/AGENTS.md +111 -0
  2. package/CHANGELOG.md +14 -0
  3. package/CONTRIBUTING.md +101 -0
  4. package/LICENSE +21 -0
  5. package/README.md +314 -0
  6. package/assets/composition-engine.mmd +34 -0
  7. package/assets/demo-script.sh +17 -0
  8. package/assets/logo-dark.svg +14 -0
  9. package/assets/logo.svg +14 -0
  10. package/assets/pipeline.mmd +39 -0
  11. package/assets/record-demo.sh +51 -0
  12. package/docs/README.md +51 -0
  13. package/docs/adapters/context-mode.md +60 -0
  14. package/docs/concepts/architecture.md +87 -0
  15. package/docs/concepts/artifact-model.md +60 -0
  16. package/docs/concepts/composition-engine.md +36 -0
  17. package/docs/concepts/indexing-and-recall.md +160 -0
  18. package/docs/concepts/observability.md +41 -0
  19. package/docs/concepts/roles-and-workflows.md +59 -0
  20. package/docs/concepts/terminology-policy.md +27 -0
  21. package/docs/getting-started/01-installation.md +78 -0
  22. package/docs/getting-started/02-first-run.md +102 -0
  23. package/docs/getting-started/03-adding-to-project.md +15 -0
  24. package/docs/getting-started/04-host-setup.md +15 -0
  25. package/docs/guides/ci-integration.md +15 -0
  26. package/docs/guides/creating-skills.md +15 -0
  27. package/docs/guides/expertise-module-authoring.md +15 -0
  28. package/docs/guides/hook-development.md +15 -0
  29. package/docs/guides/memory-and-learnings.md +34 -0
  30. package/docs/guides/multi-host-export.md +15 -0
  31. package/docs/guides/troubleshooting.md +101 -0
  32. package/docs/guides/writing-custom-roles.md +15 -0
  33. package/docs/plans/2026-03-15-cli-pipeline-integration-design.md +592 -0
  34. package/docs/plans/2026-03-15-cli-pipeline-integration-plan.md +598 -0
  35. package/docs/plans/2026-03-15-docs-enforcement-plan.md +238 -0
  36. package/docs/readmes/INDEX.md +99 -0
  37. package/docs/readmes/features/expertise/README.md +171 -0
  38. package/docs/readmes/features/exports/README.md +222 -0
  39. package/docs/readmes/features/hooks/README.md +103 -0
  40. package/docs/readmes/features/hooks/loop-cap-guard.md +133 -0
  41. package/docs/readmes/features/hooks/post-tool-capture.md +121 -0
  42. package/docs/readmes/features/hooks/post-tool-lint.md +130 -0
  43. package/docs/readmes/features/hooks/pre-compact-summary.md +122 -0
  44. package/docs/readmes/features/hooks/pre-tool-capture-route.md +100 -0
  45. package/docs/readmes/features/hooks/protected-path-write-guard.md +128 -0
  46. package/docs/readmes/features/hooks/session-start.md +119 -0
  47. package/docs/readmes/features/hooks/stop-handoff-harvest.md +125 -0
  48. package/docs/readmes/features/roles/README.md +157 -0
  49. package/docs/readmes/features/roles/clarifier.md +152 -0
  50. package/docs/readmes/features/roles/content-author.md +190 -0
  51. package/docs/readmes/features/roles/designer.md +193 -0
  52. package/docs/readmes/features/roles/executor.md +184 -0
  53. package/docs/readmes/features/roles/learner.md +210 -0
  54. package/docs/readmes/features/roles/planner.md +182 -0
  55. package/docs/readmes/features/roles/researcher.md +164 -0
  56. package/docs/readmes/features/roles/reviewer.md +184 -0
  57. package/docs/readmes/features/roles/specifier.md +162 -0
  58. package/docs/readmes/features/roles/verifier.md +215 -0
  59. package/docs/readmes/features/schemas/README.md +178 -0
  60. package/docs/readmes/features/skills/README.md +63 -0
  61. package/docs/readmes/features/skills/brainstorming.md +96 -0
  62. package/docs/readmes/features/skills/debugging.md +148 -0
  63. package/docs/readmes/features/skills/design.md +120 -0
  64. package/docs/readmes/features/skills/prepare-next.md +109 -0
  65. package/docs/readmes/features/skills/run-audit.md +159 -0
  66. package/docs/readmes/features/skills/scan-project.md +109 -0
  67. package/docs/readmes/features/skills/self-audit.md +176 -0
  68. package/docs/readmes/features/skills/tdd.md +137 -0
  69. package/docs/readmes/features/skills/using-skills.md +92 -0
  70. package/docs/readmes/features/skills/verification.md +120 -0
  71. package/docs/readmes/features/skills/writing-plans.md +104 -0
  72. package/docs/readmes/features/tooling/README.md +320 -0
  73. package/docs/readmes/features/workflows/README.md +186 -0
  74. package/docs/readmes/features/workflows/author.md +181 -0
  75. package/docs/readmes/features/workflows/clarify.md +154 -0
  76. package/docs/readmes/features/workflows/design-review.md +171 -0
  77. package/docs/readmes/features/workflows/design.md +169 -0
  78. package/docs/readmes/features/workflows/discover.md +162 -0
  79. package/docs/readmes/features/workflows/execute.md +173 -0
  80. package/docs/readmes/features/workflows/learn.md +167 -0
  81. package/docs/readmes/features/workflows/plan-review.md +165 -0
  82. package/docs/readmes/features/workflows/plan.md +170 -0
  83. package/docs/readmes/features/workflows/prepare-next.md +167 -0
  84. package/docs/readmes/features/workflows/review.md +169 -0
  85. package/docs/readmes/features/workflows/run-audit.md +191 -0
  86. package/docs/readmes/features/workflows/spec-challenge.md +159 -0
  87. package/docs/readmes/features/workflows/specify.md +160 -0
  88. package/docs/readmes/features/workflows/verify.md +177 -0
  89. package/docs/readmes/packages/README.md +50 -0
  90. package/docs/readmes/packages/ajv.md +117 -0
  91. package/docs/readmes/packages/context-mode.md +118 -0
  92. package/docs/readmes/packages/gray-matter.md +116 -0
  93. package/docs/readmes/packages/node-test.md +137 -0
  94. package/docs/readmes/packages/yaml.md +112 -0
  95. package/docs/reference/configuration-reference.md +159 -0
  96. package/docs/reference/expertise-index.md +52 -0
  97. package/docs/reference/git-flow.md +43 -0
  98. package/docs/reference/hooks.md +87 -0
  99. package/docs/reference/host-exports.md +50 -0
  100. package/docs/reference/launch-checklist.md +172 -0
  101. package/docs/reference/marketplace-listings.md +76 -0
  102. package/docs/reference/release-process.md +34 -0
  103. package/docs/reference/roles-reference.md +77 -0
  104. package/docs/reference/skills.md +33 -0
  105. package/docs/reference/templates.md +29 -0
  106. package/docs/reference/tooling-cli.md +94 -0
  107. package/docs/truth-claims.yaml +222 -0
  108. package/expertise/PROGRESS.md +63 -0
  109. package/expertise/README.md +18 -0
  110. package/expertise/antipatterns/PROGRESS.md +56 -0
  111. package/expertise/antipatterns/backend/api-design-antipatterns.md +1271 -0
  112. package/expertise/antipatterns/backend/auth-antipatterns.md +1195 -0
  113. package/expertise/antipatterns/backend/caching-antipatterns.md +622 -0
  114. package/expertise/antipatterns/backend/database-antipatterns.md +1038 -0
  115. package/expertise/antipatterns/backend/index.md +24 -0
  116. package/expertise/antipatterns/backend/microservices-antipatterns.md +850 -0
  117. package/expertise/antipatterns/code/architecture-antipatterns.md +919 -0
  118. package/expertise/antipatterns/code/async-antipatterns.md +622 -0
  119. package/expertise/antipatterns/code/code-smells.md +1186 -0
  120. package/expertise/antipatterns/code/dependency-antipatterns.md +1209 -0
  121. package/expertise/antipatterns/code/error-handling-antipatterns.md +1360 -0
  122. package/expertise/antipatterns/code/index.md +27 -0
  123. package/expertise/antipatterns/code/naming-and-abstraction.md +1118 -0
  124. package/expertise/antipatterns/code/state-management-antipatterns.md +1076 -0
  125. package/expertise/antipatterns/code/testing-antipatterns.md +1053 -0
  126. package/expertise/antipatterns/design/accessibility-antipatterns.md +1136 -0
  127. package/expertise/antipatterns/design/dark-patterns.md +1121 -0
  128. package/expertise/antipatterns/design/index.md +22 -0
  129. package/expertise/antipatterns/design/ui-antipatterns.md +1202 -0
  130. package/expertise/antipatterns/design/ux-antipatterns.md +680 -0
  131. package/expertise/antipatterns/frontend/css-layout-antipatterns.md +691 -0
  132. package/expertise/antipatterns/frontend/flutter-antipatterns.md +1827 -0
  133. package/expertise/antipatterns/frontend/index.md +23 -0
  134. package/expertise/antipatterns/frontend/mobile-antipatterns.md +573 -0
  135. package/expertise/antipatterns/frontend/react-antipatterns.md +1128 -0
  136. package/expertise/antipatterns/frontend/spa-antipatterns.md +1235 -0
  137. package/expertise/antipatterns/index.md +31 -0
  138. package/expertise/antipatterns/performance/index.md +20 -0
  139. package/expertise/antipatterns/performance/performance-antipatterns.md +1013 -0
  140. package/expertise/antipatterns/performance/premature-optimization.md +623 -0
  141. package/expertise/antipatterns/performance/scaling-antipatterns.md +785 -0
  142. package/expertise/antipatterns/process/ai-coding-antipatterns.md +853 -0
  143. package/expertise/antipatterns/process/code-review-antipatterns.md +656 -0
  144. package/expertise/antipatterns/process/deployment-antipatterns.md +920 -0
  145. package/expertise/antipatterns/process/index.md +23 -0
  146. package/expertise/antipatterns/process/technical-debt-antipatterns.md +647 -0
  147. package/expertise/antipatterns/security/index.md +20 -0
  148. package/expertise/antipatterns/security/secrets-antipatterns.md +849 -0
  149. package/expertise/antipatterns/security/security-theater.md +843 -0
  150. package/expertise/antipatterns/security/vulnerability-patterns.md +801 -0
  151. package/expertise/architecture/PROGRESS.md +70 -0
  152. package/expertise/architecture/data/caching-architecture.md +671 -0
  153. package/expertise/architecture/data/data-consistency.md +574 -0
  154. package/expertise/architecture/data/data-modeling.md +536 -0
  155. package/expertise/architecture/data/event-streams-and-queues.md +634 -0
  156. package/expertise/architecture/data/index.md +25 -0
  157. package/expertise/architecture/data/search-architecture.md +663 -0
  158. package/expertise/architecture/data/sql-vs-nosql.md +708 -0
  159. package/expertise/architecture/decisions/architecture-decision-records.md +640 -0
  160. package/expertise/architecture/decisions/build-vs-buy.md +616 -0
  161. package/expertise/architecture/decisions/index.md +23 -0
  162. package/expertise/architecture/decisions/monolith-to-microservices.md +790 -0
  163. package/expertise/architecture/decisions/technology-selection.md +616 -0
  164. package/expertise/architecture/distributed/cap-theorem-and-tradeoffs.md +800 -0
  165. package/expertise/architecture/distributed/circuit-breaker-bulkhead.md +741 -0
  166. package/expertise/architecture/distributed/consensus-and-coordination.md +796 -0
  167. package/expertise/architecture/distributed/distributed-systems-fundamentals.md +564 -0
  168. package/expertise/architecture/distributed/idempotency-and-retry.md +796 -0
  169. package/expertise/architecture/distributed/index.md +25 -0
  170. package/expertise/architecture/distributed/saga-pattern.md +797 -0
  171. package/expertise/architecture/foundations/architectural-thinking.md +460 -0
  172. package/expertise/architecture/foundations/coupling-and-cohesion.md +770 -0
  173. package/expertise/architecture/foundations/design-principles-solid.md +649 -0
  174. package/expertise/architecture/foundations/domain-driven-design.md +719 -0
  175. package/expertise/architecture/foundations/index.md +25 -0
  176. package/expertise/architecture/foundations/separation-of-concerns.md +472 -0
  177. package/expertise/architecture/foundations/twelve-factor-app.md +797 -0
  178. package/expertise/architecture/index.md +34 -0
  179. package/expertise/architecture/integration/api-design-graphql.md +638 -0
  180. package/expertise/architecture/integration/api-design-grpc.md +804 -0
  181. package/expertise/architecture/integration/api-design-rest.md +892 -0
  182. package/expertise/architecture/integration/index.md +25 -0
  183. package/expertise/architecture/integration/third-party-integration.md +795 -0
  184. package/expertise/architecture/integration/webhooks-and-callbacks.md +1152 -0
  185. package/expertise/architecture/integration/websockets-realtime.md +791 -0
  186. package/expertise/architecture/mobile-architecture/index.md +22 -0
  187. package/expertise/architecture/mobile-architecture/mobile-app-architecture.md +780 -0
  188. package/expertise/architecture/mobile-architecture/mobile-backend-for-frontend.md +670 -0
  189. package/expertise/architecture/mobile-architecture/offline-first.md +719 -0
  190. package/expertise/architecture/mobile-architecture/push-and-sync.md +782 -0
  191. package/expertise/architecture/patterns/cqrs-event-sourcing.md +717 -0
  192. package/expertise/architecture/patterns/event-driven.md +797 -0
  193. package/expertise/architecture/patterns/hexagonal-clean-architecture.md +870 -0
  194. package/expertise/architecture/patterns/index.md +27 -0
  195. package/expertise/architecture/patterns/layered-architecture.md +736 -0
  196. package/expertise/architecture/patterns/microservices.md +753 -0
  197. package/expertise/architecture/patterns/modular-monolith.md +692 -0
  198. package/expertise/architecture/patterns/monolith.md +626 -0
  199. package/expertise/architecture/patterns/plugin-architecture.md +735 -0
  200. package/expertise/architecture/patterns/serverless.md +780 -0
  201. package/expertise/architecture/scaling/database-scaling.md +615 -0
  202. package/expertise/architecture/scaling/feature-flags-and-rollouts.md +757 -0
  203. package/expertise/architecture/scaling/horizontal-vs-vertical.md +606 -0
  204. package/expertise/architecture/scaling/index.md +24 -0
  205. package/expertise/architecture/scaling/multi-tenancy.md +800 -0
  206. package/expertise/architecture/scaling/stateless-design.md +787 -0
  207. package/expertise/backend/embedded-firmware.md +625 -0
  208. package/expertise/backend/go.md +853 -0
  209. package/expertise/backend/index.md +24 -0
  210. package/expertise/backend/java-spring.md +448 -0
  211. package/expertise/backend/node-typescript.md +625 -0
  212. package/expertise/backend/python-fastapi.md +724 -0
  213. package/expertise/backend/rust.md +458 -0
  214. package/expertise/backend/solidity.md +711 -0
  215. package/expertise/composition-map.yaml +443 -0
  216. package/expertise/content/foundations/content-modeling.md +395 -0
  217. package/expertise/content/foundations/editorial-standards.md +449 -0
  218. package/expertise/content/foundations/index.md +24 -0
  219. package/expertise/content/foundations/microcopy.md +455 -0
  220. package/expertise/content/foundations/terminology-governance.md +509 -0
  221. package/expertise/content/index.md +34 -0
  222. package/expertise/content/patterns/accessibility-copy.md +518 -0
  223. package/expertise/content/patterns/index.md +24 -0
  224. package/expertise/content/patterns/notification-content.md +433 -0
  225. package/expertise/content/patterns/sample-content.md +486 -0
  226. package/expertise/content/patterns/state-copy.md +439 -0
  227. package/expertise/design/PROGRESS.md +58 -0
  228. package/expertise/design/disciplines/dark-mode-theming.md +577 -0
  229. package/expertise/design/disciplines/design-systems.md +595 -0
  230. package/expertise/design/disciplines/index.md +25 -0
  231. package/expertise/design/disciplines/information-architecture.md +800 -0
  232. package/expertise/design/disciplines/interaction-design.md +788 -0
  233. package/expertise/design/disciplines/responsive-design.md +552 -0
  234. package/expertise/design/disciplines/usability-testing.md +516 -0
  235. package/expertise/design/disciplines/user-research.md +792 -0
  236. package/expertise/design/foundations/accessibility-design.md +796 -0
  237. package/expertise/design/foundations/color-theory.md +797 -0
  238. package/expertise/design/foundations/iconography.md +795 -0
  239. package/expertise/design/foundations/index.md +26 -0
  240. package/expertise/design/foundations/motion-and-animation.md +653 -0
  241. package/expertise/design/foundations/rtl-design.md +585 -0
  242. package/expertise/design/foundations/spacing-and-layout.md +607 -0
  243. package/expertise/design/foundations/typography.md +800 -0
  244. package/expertise/design/foundations/visual-hierarchy.md +761 -0
  245. package/expertise/design/index.md +32 -0
  246. package/expertise/design/patterns/authentication-flows.md +474 -0
  247. package/expertise/design/patterns/content-consumption.md +789 -0
  248. package/expertise/design/patterns/data-display.md +618 -0
  249. package/expertise/design/patterns/e-commerce.md +1494 -0
  250. package/expertise/design/patterns/feedback-and-states.md +642 -0
  251. package/expertise/design/patterns/forms-and-input.md +819 -0
  252. package/expertise/design/patterns/gamification.md +801 -0
  253. package/expertise/design/patterns/index.md +31 -0
  254. package/expertise/design/patterns/microinteractions.md +449 -0
  255. package/expertise/design/patterns/navigation.md +800 -0
  256. package/expertise/design/patterns/notifications.md +705 -0
  257. package/expertise/design/patterns/onboarding.md +700 -0
  258. package/expertise/design/patterns/search-and-filter.md +601 -0
  259. package/expertise/design/patterns/settings-and-preferences.md +768 -0
  260. package/expertise/design/patterns/social-and-community.md +748 -0
  261. package/expertise/design/platforms/desktop-native.md +612 -0
  262. package/expertise/design/platforms/index.md +25 -0
  263. package/expertise/design/platforms/mobile-android.md +825 -0
  264. package/expertise/design/platforms/mobile-cross-platform.md +983 -0
  265. package/expertise/design/platforms/mobile-ios.md +699 -0
  266. package/expertise/design/platforms/tablet.md +794 -0
  267. package/expertise/design/platforms/web-dashboard.md +790 -0
  268. package/expertise/design/platforms/web-responsive.md +550 -0
  269. package/expertise/design/psychology/behavioral-nudges.md +449 -0
  270. package/expertise/design/psychology/cognitive-load.md +1191 -0
  271. package/expertise/design/psychology/error-psychology.md +778 -0
  272. package/expertise/design/psychology/index.md +22 -0
  273. package/expertise/design/psychology/persuasive-design.md +736 -0
  274. package/expertise/design/psychology/user-mental-models.md +623 -0
  275. package/expertise/design/tooling/open-pencil.md +266 -0
  276. package/expertise/frontend/angular.md +1073 -0
  277. package/expertise/frontend/desktop-electron.md +546 -0
  278. package/expertise/frontend/flutter.md +782 -0
  279. package/expertise/frontend/index.md +27 -0
  280. package/expertise/frontend/native-android.md +409 -0
  281. package/expertise/frontend/native-ios.md +490 -0
  282. package/expertise/frontend/react-native.md +1160 -0
  283. package/expertise/frontend/react.md +808 -0
  284. package/expertise/frontend/vue.md +1089 -0
  285. package/expertise/humanize/domain-rules-code.md +79 -0
  286. package/expertise/humanize/domain-rules-content.md +67 -0
  287. package/expertise/humanize/domain-rules-technical-docs.md +56 -0
  288. package/expertise/humanize/index.md +35 -0
  289. package/expertise/humanize/self-audit-checklist.md +87 -0
  290. package/expertise/humanize/sentence-patterns.md +218 -0
  291. package/expertise/humanize/vocabulary-blacklist.md +105 -0
  292. package/expertise/i18n/PROGRESS.md +65 -0
  293. package/expertise/i18n/advanced/accessibility-and-i18n.md +28 -0
  294. package/expertise/i18n/advanced/bidirectional-text-algorithm.md +38 -0
  295. package/expertise/i18n/advanced/complex-scripts.md +30 -0
  296. package/expertise/i18n/advanced/performance-and-i18n.md +27 -0
  297. package/expertise/i18n/advanced/testing-i18n.md +28 -0
  298. package/expertise/i18n/content/content-adaptation.md +23 -0
  299. package/expertise/i18n/content/locale-specific-formatting.md +23 -0
  300. package/expertise/i18n/content/machine-translation-integration.md +28 -0
  301. package/expertise/i18n/content/translation-management.md +29 -0
  302. package/expertise/i18n/foundations/date-time-calendars.md +67 -0
  303. package/expertise/i18n/foundations/i18n-architecture.md +272 -0
  304. package/expertise/i18n/foundations/locale-and-language-tags.md +79 -0
  305. package/expertise/i18n/foundations/numbers-currency-units.md +61 -0
  306. package/expertise/i18n/foundations/pluralization-and-gender.md +109 -0
  307. package/expertise/i18n/foundations/string-externalization.md +236 -0
  308. package/expertise/i18n/foundations/text-direction-bidi.md +241 -0
  309. package/expertise/i18n/foundations/unicode-and-encoding.md +86 -0
  310. package/expertise/i18n/index.md +38 -0
  311. package/expertise/i18n/platform/backend-i18n.md +31 -0
  312. package/expertise/i18n/platform/flutter-i18n.md +148 -0
  313. package/expertise/i18n/platform/native-android-i18n.md +36 -0
  314. package/expertise/i18n/platform/native-ios-i18n.md +36 -0
  315. package/expertise/i18n/platform/react-i18n.md +103 -0
  316. package/expertise/i18n/platform/web-css-i18n.md +81 -0
  317. package/expertise/i18n/rtl/arabic-specific.md +175 -0
  318. package/expertise/i18n/rtl/hebrew-specific.md +149 -0
  319. package/expertise/i18n/rtl/rtl-animations-and-transitions.md +111 -0
  320. package/expertise/i18n/rtl/rtl-forms-and-input.md +161 -0
  321. package/expertise/i18n/rtl/rtl-fundamentals.md +211 -0
  322. package/expertise/i18n/rtl/rtl-icons-and-images.md +181 -0
  323. package/expertise/i18n/rtl/rtl-layout-mirroring.md +252 -0
  324. package/expertise/i18n/rtl/rtl-navigation-and-gestures.md +107 -0
  325. package/expertise/i18n/rtl/rtl-testing-and-qa.md +147 -0
  326. package/expertise/i18n/rtl/rtl-typography.md +160 -0
  327. package/expertise/index.md +113 -0
  328. package/expertise/index.yaml +216 -0
  329. package/expertise/infrastructure/cloud-aws.md +597 -0
  330. package/expertise/infrastructure/cloud-gcp.md +599 -0
  331. package/expertise/infrastructure/cybersecurity.md +816 -0
  332. package/expertise/infrastructure/database-mongodb.md +447 -0
  333. package/expertise/infrastructure/database-postgres.md +400 -0
  334. package/expertise/infrastructure/devops-cicd.md +787 -0
  335. package/expertise/infrastructure/index.md +27 -0
  336. package/expertise/performance/PROGRESS.md +50 -0
  337. package/expertise/performance/backend/api-latency.md +1204 -0
  338. package/expertise/performance/backend/background-jobs.md +506 -0
  339. package/expertise/performance/backend/connection-pooling.md +1209 -0
  340. package/expertise/performance/backend/database-query-optimization.md +515 -0
  341. package/expertise/performance/backend/index.md +23 -0
  342. package/expertise/performance/backend/rate-limiting-and-throttling.md +971 -0
  343. package/expertise/performance/foundations/algorithmic-complexity.md +954 -0
  344. package/expertise/performance/foundations/caching-strategies.md +489 -0
  345. package/expertise/performance/foundations/concurrency-and-parallelism.md +847 -0
  346. package/expertise/performance/foundations/index.md +24 -0
  347. package/expertise/performance/foundations/measuring-and-profiling.md +440 -0
  348. package/expertise/performance/foundations/memory-management.md +964 -0
  349. package/expertise/performance/foundations/performance-budgets.md +1314 -0
  350. package/expertise/performance/index.md +31 -0
  351. package/expertise/performance/infrastructure/auto-scaling.md +1059 -0
  352. package/expertise/performance/infrastructure/cdn-and-edge.md +1081 -0
  353. package/expertise/performance/infrastructure/index.md +22 -0
  354. package/expertise/performance/infrastructure/load-balancing.md +1081 -0
  355. package/expertise/performance/infrastructure/observability.md +1079 -0
  356. package/expertise/performance/mobile/index.md +23 -0
  357. package/expertise/performance/mobile/mobile-animations.md +544 -0
  358. package/expertise/performance/mobile/mobile-memory-battery.md +416 -0
  359. package/expertise/performance/mobile/mobile-network.md +452 -0
  360. package/expertise/performance/mobile/mobile-rendering.md +599 -0
  361. package/expertise/performance/mobile/mobile-startup-time.md +505 -0
  362. package/expertise/performance/platform-specific/flutter-performance.md +647 -0
  363. package/expertise/performance/platform-specific/index.md +22 -0
  364. package/expertise/performance/platform-specific/node-performance.md +1307 -0
  365. package/expertise/performance/platform-specific/postgres-performance.md +1366 -0
  366. package/expertise/performance/platform-specific/react-performance.md +1403 -0
  367. package/expertise/performance/web/bundle-optimization.md +1239 -0
  368. package/expertise/performance/web/image-and-media.md +636 -0
  369. package/expertise/performance/web/index.md +24 -0
  370. package/expertise/performance/web/network-optimization.md +1133 -0
  371. package/expertise/performance/web/rendering-performance.md +1098 -0
  372. package/expertise/performance/web/ssr-and-hydration.md +918 -0
  373. package/expertise/performance/web/web-vitals.md +1374 -0
  374. package/expertise/quality/accessibility.md +985 -0
  375. package/expertise/quality/evidence-based-verification.md +499 -0
  376. package/expertise/quality/index.md +24 -0
  377. package/expertise/quality/ml-model-audit.md +614 -0
  378. package/expertise/quality/performance.md +600 -0
  379. package/expertise/quality/testing-api.md +891 -0
  380. package/expertise/quality/testing-mobile.md +496 -0
  381. package/expertise/quality/testing-web.md +849 -0
  382. package/expertise/security/PROGRESS.md +54 -0
  383. package/expertise/security/agentic-identity.md +540 -0
  384. package/expertise/security/compliance-frameworks.md +601 -0
  385. package/expertise/security/data/data-encryption.md +364 -0
  386. package/expertise/security/data/data-privacy-gdpr.md +692 -0
  387. package/expertise/security/data/database-security.md +1171 -0
  388. package/expertise/security/data/index.md +22 -0
  389. package/expertise/security/data/pii-handling.md +531 -0
  390. package/expertise/security/foundations/authentication.md +1041 -0
  391. package/expertise/security/foundations/authorization.md +603 -0
  392. package/expertise/security/foundations/cryptography.md +1001 -0
  393. package/expertise/security/foundations/index.md +25 -0
  394. package/expertise/security/foundations/owasp-top-10.md +1354 -0
  395. package/expertise/security/foundations/secrets-management.md +1217 -0
  396. package/expertise/security/foundations/secure-sdlc.md +700 -0
  397. package/expertise/security/foundations/supply-chain-security.md +698 -0
  398. package/expertise/security/index.md +31 -0
  399. package/expertise/security/infrastructure/cloud-security-aws.md +1296 -0
  400. package/expertise/security/infrastructure/cloud-security-gcp.md +1376 -0
  401. package/expertise/security/infrastructure/container-security.md +721 -0
  402. package/expertise/security/infrastructure/incident-response.md +1295 -0
  403. package/expertise/security/infrastructure/index.md +24 -0
  404. package/expertise/security/infrastructure/logging-and-monitoring.md +1618 -0
  405. package/expertise/security/infrastructure/network-security.md +1337 -0
  406. package/expertise/security/mobile/index.md +23 -0
  407. package/expertise/security/mobile/mobile-android-security.md +1218 -0
  408. package/expertise/security/mobile/mobile-binary-protection.md +1229 -0
  409. package/expertise/security/mobile/mobile-data-storage.md +1265 -0
  410. package/expertise/security/mobile/mobile-ios-security.md +1401 -0
  411. package/expertise/security/mobile/mobile-network-security.md +1520 -0
  412. package/expertise/security/smart-contract-security.md +594 -0
  413. package/expertise/security/testing/index.md +22 -0
  414. package/expertise/security/testing/penetration-testing.md +1258 -0
  415. package/expertise/security/testing/security-code-review.md +1765 -0
  416. package/expertise/security/testing/threat-modeling.md +1074 -0
  417. package/expertise/security/testing/vulnerability-scanning.md +1062 -0
  418. package/expertise/security/web/api-security.md +586 -0
  419. package/expertise/security/web/cors-and-headers.md +433 -0
  420. package/expertise/security/web/csrf.md +562 -0
  421. package/expertise/security/web/file-upload.md +1477 -0
  422. package/expertise/security/web/index.md +25 -0
  423. package/expertise/security/web/injection.md +1375 -0
  424. package/expertise/security/web/session-management.md +1101 -0
  425. package/expertise/security/web/xss.md +1158 -0
  426. package/exports/README.md +17 -0
  427. package/exports/hosts/claude/.claude/agents/clarifier.md +42 -0
  428. package/exports/hosts/claude/.claude/agents/content-author.md +63 -0
  429. package/exports/hosts/claude/.claude/agents/designer.md +55 -0
  430. package/exports/hosts/claude/.claude/agents/executor.md +55 -0
  431. package/exports/hosts/claude/.claude/agents/learner.md +51 -0
  432. package/exports/hosts/claude/.claude/agents/planner.md +53 -0
  433. package/exports/hosts/claude/.claude/agents/researcher.md +43 -0
  434. package/exports/hosts/claude/.claude/agents/reviewer.md +54 -0
  435. package/exports/hosts/claude/.claude/agents/specifier.md +47 -0
  436. package/exports/hosts/claude/.claude/agents/verifier.md +71 -0
  437. package/exports/hosts/claude/.claude/commands/author.md +42 -0
  438. package/exports/hosts/claude/.claude/commands/clarify.md +38 -0
  439. package/exports/hosts/claude/.claude/commands/design-review.md +46 -0
  440. package/exports/hosts/claude/.claude/commands/design.md +44 -0
  441. package/exports/hosts/claude/.claude/commands/discover.md +37 -0
  442. package/exports/hosts/claude/.claude/commands/execute.md +48 -0
  443. package/exports/hosts/claude/.claude/commands/learn.md +38 -0
  444. package/exports/hosts/claude/.claude/commands/plan-review.md +42 -0
  445. package/exports/hosts/claude/.claude/commands/plan.md +39 -0
  446. package/exports/hosts/claude/.claude/commands/prepare-next.md +37 -0
  447. package/exports/hosts/claude/.claude/commands/review.md +40 -0
  448. package/exports/hosts/claude/.claude/commands/run-audit.md +41 -0
  449. package/exports/hosts/claude/.claude/commands/spec-challenge.md +41 -0
  450. package/exports/hosts/claude/.claude/commands/specify.md +38 -0
  451. package/exports/hosts/claude/.claude/commands/verify.md +37 -0
  452. package/exports/hosts/claude/.claude/settings.json +34 -0
  453. package/exports/hosts/claude/CLAUDE.md +19 -0
  454. package/exports/hosts/claude/export.manifest.json +38 -0
  455. package/exports/hosts/claude/host-package.json +67 -0
  456. package/exports/hosts/codex/AGENTS.md +19 -0
  457. package/exports/hosts/codex/export.manifest.json +38 -0
  458. package/exports/hosts/codex/host-package.json +41 -0
  459. package/exports/hosts/cursor/.cursor/hooks.json +16 -0
  460. package/exports/hosts/cursor/.cursor/rules/wazir-core.mdc +19 -0
  461. package/exports/hosts/cursor/export.manifest.json +38 -0
  462. package/exports/hosts/cursor/host-package.json +42 -0
  463. package/exports/hosts/gemini/GEMINI.md +19 -0
  464. package/exports/hosts/gemini/export.manifest.json +38 -0
  465. package/exports/hosts/gemini/host-package.json +41 -0
  466. package/hooks/README.md +18 -0
  467. package/hooks/definitions/loop_cap_guard.yaml +21 -0
  468. package/hooks/definitions/post_tool_capture.yaml +24 -0
  469. package/hooks/definitions/pre_compact_summary.yaml +19 -0
  470. package/hooks/definitions/pre_tool_capture_route.yaml +19 -0
  471. package/hooks/definitions/protected_path_write_guard.yaml +19 -0
  472. package/hooks/definitions/session_start.yaml +19 -0
  473. package/hooks/definitions/stop_handoff_harvest.yaml +20 -0
  474. package/hooks/loop-cap-guard +17 -0
  475. package/hooks/post-tool-lint +36 -0
  476. package/hooks/protected-path-write-guard +17 -0
  477. package/hooks/session-start +41 -0
  478. package/llms-full.txt +2355 -0
  479. package/llms.txt +43 -0
  480. package/package.json +79 -0
  481. package/roles/README.md +20 -0
  482. package/roles/clarifier.md +42 -0
  483. package/roles/content-author.md +63 -0
  484. package/roles/designer.md +55 -0
  485. package/roles/executor.md +55 -0
  486. package/roles/learner.md +51 -0
  487. package/roles/planner.md +53 -0
  488. package/roles/researcher.md +43 -0
  489. package/roles/reviewer.md +54 -0
  490. package/roles/specifier.md +47 -0
  491. package/roles/verifier.md +71 -0
  492. package/schemas/README.md +24 -0
  493. package/schemas/accepted-learning.schema.json +20 -0
  494. package/schemas/author-artifact.schema.json +156 -0
  495. package/schemas/clarification.schema.json +19 -0
  496. package/schemas/design-artifact.schema.json +80 -0
  497. package/schemas/docs-claim.schema.json +18 -0
  498. package/schemas/export-manifest.schema.json +20 -0
  499. package/schemas/hook.schema.json +67 -0
  500. package/schemas/host-export-package.schema.json +18 -0
  501. package/schemas/implementation-plan.schema.json +19 -0
  502. package/schemas/proposed-learning.schema.json +19 -0
  503. package/schemas/research.schema.json +18 -0
  504. package/schemas/review.schema.json +29 -0
  505. package/schemas/run-manifest.schema.json +18 -0
  506. package/schemas/spec-challenge.schema.json +18 -0
  507. package/schemas/spec.schema.json +20 -0
  508. package/schemas/usage.schema.json +102 -0
  509. package/schemas/verification-proof.schema.json +29 -0
  510. package/schemas/wazir-manifest.schema.json +173 -0
  511. package/skills/README.md +40 -0
  512. package/skills/brainstorming/SKILL.md +77 -0
  513. package/skills/debugging/SKILL.md +50 -0
  514. package/skills/design/SKILL.md +61 -0
  515. package/skills/dispatching-parallel-agents/SKILL.md +128 -0
  516. package/skills/executing-plans/SKILL.md +70 -0
  517. package/skills/finishing-a-development-branch/SKILL.md +169 -0
  518. package/skills/humanize/SKILL.md +123 -0
  519. package/skills/init-pipeline/SKILL.md +124 -0
  520. package/skills/prepare-next/SKILL.md +20 -0
  521. package/skills/receiving-code-review/SKILL.md +123 -0
  522. package/skills/requesting-code-review/SKILL.md +105 -0
  523. package/skills/requesting-code-review/code-reviewer.md +108 -0
  524. package/skills/run-audit/SKILL.md +197 -0
  525. package/skills/scan-project/SKILL.md +41 -0
  526. package/skills/self-audit/SKILL.md +153 -0
  527. package/skills/subagent-driven-development/SKILL.md +154 -0
  528. package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +26 -0
  529. package/skills/subagent-driven-development/implementer-prompt.md +102 -0
  530. package/skills/subagent-driven-development/spec-reviewer-prompt.md +61 -0
  531. package/skills/tdd/SKILL.md +23 -0
  532. package/skills/using-git-worktrees/SKILL.md +163 -0
  533. package/skills/using-skills/SKILL.md +95 -0
  534. package/skills/verification/SKILL.md +22 -0
  535. package/skills/wazir/SKILL.md +463 -0
  536. package/skills/writing-plans/SKILL.md +30 -0
  537. package/skills/writing-skills/SKILL.md +157 -0
  538. package/skills/writing-skills/anthropic-best-practices.md +122 -0
  539. package/skills/writing-skills/persuasion-principles.md +50 -0
  540. package/templates/README.md +20 -0
  541. package/templates/artifacts/README.md +10 -0
  542. package/templates/artifacts/accepted-learning.md +19 -0
  543. package/templates/artifacts/accepted-learning.template.json +12 -0
  544. package/templates/artifacts/author.md +74 -0
  545. package/templates/artifacts/author.template.json +19 -0
  546. package/templates/artifacts/clarification.md +21 -0
  547. package/templates/artifacts/clarification.template.json +12 -0
  548. package/templates/artifacts/execute-notes.md +19 -0
  549. package/templates/artifacts/implementation-plan.md +21 -0
  550. package/templates/artifacts/implementation-plan.template.json +11 -0
  551. package/templates/artifacts/learning-proposal.md +19 -0
  552. package/templates/artifacts/next-run-handoff.md +21 -0
  553. package/templates/artifacts/plan-review.md +19 -0
  554. package/templates/artifacts/proposed-learning.template.json +12 -0
  555. package/templates/artifacts/research.md +21 -0
  556. package/templates/artifacts/research.template.json +12 -0
  557. package/templates/artifacts/review-findings.md +19 -0
  558. package/templates/artifacts/review.template.json +11 -0
  559. package/templates/artifacts/run-manifest.template.json +8 -0
  560. package/templates/artifacts/spec-challenge.md +19 -0
  561. package/templates/artifacts/spec-challenge.template.json +11 -0
  562. package/templates/artifacts/spec.md +21 -0
  563. package/templates/artifacts/spec.template.json +12 -0
  564. package/templates/artifacts/verification-proof.md +19 -0
  565. package/templates/artifacts/verification-proof.template.json +11 -0
  566. package/templates/examples/accepted-learning.example.json +14 -0
  567. package/templates/examples/author.example.json +152 -0
  568. package/templates/examples/clarification.example.json +15 -0
  569. package/templates/examples/docs-claim.example.json +8 -0
  570. package/templates/examples/export-manifest.example.json +7 -0
  571. package/templates/examples/host-export-package.example.json +11 -0
  572. package/templates/examples/implementation-plan.example.json +17 -0
  573. package/templates/examples/proposed-learning.example.json +13 -0
  574. package/templates/examples/research.example.json +15 -0
  575. package/templates/examples/research.example.md +6 -0
  576. package/templates/examples/review.example.json +17 -0
  577. package/templates/examples/run-manifest.example.json +9 -0
  578. package/templates/examples/spec-challenge.example.json +14 -0
  579. package/templates/examples/spec.example.json +21 -0
  580. package/templates/examples/verification-proof.example.json +21 -0
  581. package/templates/examples/wazir-manifest.example.yaml +65 -0
  582. package/templates/task-definition-schema.md +99 -0
  583. package/tooling/README.md +20 -0
  584. package/tooling/src/adapters/context-mode.js +50 -0
  585. package/tooling/src/capture/command.js +376 -0
  586. package/tooling/src/capture/store.js +99 -0
  587. package/tooling/src/capture/usage.js +270 -0
  588. package/tooling/src/checks/branches.js +50 -0
  589. package/tooling/src/checks/brand-truth.js +110 -0
  590. package/tooling/src/checks/changelog.js +231 -0
  591. package/tooling/src/checks/command-registry.js +36 -0
  592. package/tooling/src/checks/commits.js +102 -0
  593. package/tooling/src/checks/docs-drift.js +103 -0
  594. package/tooling/src/checks/docs-truth.js +201 -0
  595. package/tooling/src/checks/runtime-surface.js +156 -0
  596. package/tooling/src/cli.js +116 -0
  597. package/tooling/src/command-options.js +56 -0
  598. package/tooling/src/commands/validate.js +320 -0
  599. package/tooling/src/doctor/command.js +91 -0
  600. package/tooling/src/export/command.js +77 -0
  601. package/tooling/src/export/compiler.js +498 -0
  602. package/tooling/src/guards/loop-cap-guard.js +52 -0
  603. package/tooling/src/guards/protected-path-write-guard.js +67 -0
  604. package/tooling/src/index/command.js +152 -0
  605. package/tooling/src/index/storage.js +1061 -0
  606. package/tooling/src/index/summarizers.js +261 -0
  607. package/tooling/src/loaders.js +18 -0
  608. package/tooling/src/project-root.js +22 -0
  609. package/tooling/src/recall/command.js +225 -0
  610. package/tooling/src/schema-validator.js +30 -0
  611. package/tooling/src/state-root.js +40 -0
  612. package/tooling/src/status/command.js +71 -0
  613. package/wazir.manifest.yaml +135 -0
  614. package/workflows/README.md +19 -0
  615. package/workflows/author.md +42 -0
  616. package/workflows/clarify.md +38 -0
  617. package/workflows/design-review.md +46 -0
  618. package/workflows/design.md +44 -0
  619. package/workflows/discover.md +37 -0
  620. package/workflows/execute.md +48 -0
  621. package/workflows/learn.md +38 -0
  622. package/workflows/plan-review.md +42 -0
  623. package/workflows/plan.md +39 -0
  624. package/workflows/prepare-next.md +37 -0
  625. package/workflows/review.md +40 -0
  626. package/workflows/run-audit.md +41 -0
  627. package/workflows/spec-challenge.md +41 -0
  628. package/workflows/specify.md +38 -0
  629. package/workflows/verify.md +37 -0
@@ -0,0 +1,918 @@
1
+ # SSR & Hydration: Performance Expertise Module
2
+
3
+ > **Scope**: Server-side rendering strategies, hydration cost analysis, streaming architectures,
4
+ > and modern rendering patterns for optimal web performance.
5
+ >
6
+ > **Last updated**: 2026-03-08
7
+
8
+ ---
9
+
10
+ ## Table of Contents
11
+
12
+ 1. [Rendering Strategies Compared](#1-rendering-strategies-compared)
13
+ 2. [The Hydration Cost Problem](#2-the-hydration-cost-problem)
14
+ 3. [Streaming SSR](#3-streaming-ssr)
15
+ 4. [React Server Components](#4-react-server-components)
16
+ 5. [Islands Architecture](#5-islands-architecture)
17
+ 6. [Progressive and Lazy Hydration](#6-progressive-and-lazy-hydration)
18
+ 7. [Resumability: The Post-Hydration Paradigm](#7-resumability-the-post-hydration-paradigm)
19
+ 8. [Edge Rendering](#8-edge-rendering)
20
+ 9. [Common Bottlenecks](#9-common-bottlenecks)
21
+ 10. [Anti-Patterns](#10-anti-patterns)
22
+ 11. [Before/After Case Studies](#11-beforeafter-case-studies)
23
+ 12. [Decision Tree: Should I Use SSR?](#12-decision-tree-should-i-use-ssr)
24
+ 13. [Implementation Checklist](#13-implementation-checklist)
25
+ 14. [Sources](#14-sources)
26
+
27
+ ---
28
+
29
+ ## 1. Rendering Strategies Compared
30
+
31
+ ### 1.1 Overview Matrix
32
+
33
+ | Strategy | TTFB | FCP | LCP | TTI | SEO | Dynamic Data | Build Cost |
34
+ |----------|------|-----|-----|-----|-----|-------------|------------|
35
+ | **CSR** | 50-100ms | 1.5-3.5s | 2.5-5.0s | 3.5-7.0s | Poor | Excellent | Low |
36
+ | **SSR** | 200-600ms | 0.8-1.5s | 1.2-2.5s | 2.0-4.5s | Excellent | Excellent | Medium |
37
+ | **SSG** | 20-50ms | 0.4-0.8s | 0.6-1.2s | 0.6-1.5s | Excellent | None | High at scale |
38
+ | **ISR** | 20-50ms* | 0.4-0.8s | 0.6-1.2s | 0.6-1.5s | Excellent | Periodic | Medium |
39
+ | **Streaming SSR** | 40-150ms | 0.5-1.0s | 1.0-2.0s | 1.5-3.5s | Excellent | Excellent | Medium |
40
+
41
+ *ISR serves from CDN cache after first generation; subsequent requests match SSG performance.
42
+
43
+ ### 1.2 Client-Side Rendering (CSR)
44
+
45
+ CSR downloads a minimal HTML shell and renders everything via JavaScript in the browser.
46
+
47
+ **Performance profile**:
48
+ - TTFB is fast (50-100ms) because the server sends a near-empty HTML document
49
+ - FCP is delayed (1.5-3.5s) because the browser must download, parse, and execute the JS bundle
50
+ before any meaningful content appears
51
+ - LCP suffers further (2.5-5.0s) because data fetching only begins after JS execution
52
+ - TTI can reach 3.5-7.0s on mobile devices due to the full JS parse-and-execute cycle
53
+
54
+ **When CSR wins**: Internal dashboards, authenticated apps where SEO is irrelevant, and
55
+ applications with heavy real-time interactivity (collaborative editors, trading platforms).
56
+
57
+ ### 1.3 Server-Side Rendering (SSR)
58
+
59
+ SSR generates full HTML on the server for every request.
60
+
61
+ **Performance profile**:
62
+ - TTFB is slower (200-600ms) because the server must fetch data and render HTML before responding
63
+ - FCP is significantly faster (0.8-1.5s) because the browser receives ready-to-paint HTML
64
+ - LCP improves (1.2-2.5s) since the image/element is present in the HTML source, not injected by JS
65
+ - TTI can lag behind FCP by 1-3 seconds due to hydration cost
66
+
67
+ Per web.dev guidelines, SSR is preferred over CSR for LCP because the full page markup, including
68
+ images, is present in the HTML source. CSR solutions require JavaScript to run before the image
69
+ can be discovered, which delays LCP.
70
+
71
+ **Database I/O is the real bottleneck**: If a database is 50ms away from the app server and a page
72
+ makes 3 sequential queries, that is 150ms for data alone. Add 50-100ms for SSR rendering, yielding
73
+ a 200-250ms baseline TTFB before any cold-start overhead.
74
+
75
+ ### 1.4 Static Site Generation (SSG)
76
+
77
+ SSG pre-renders pages at build time, serving them as static HTML from a CDN.
78
+
79
+ **Performance profile**:
80
+ - TTFB is minimal (20-50ms) since pages are pre-built and served from edge CDN
81
+ - All loading metrics are near-optimal because no server computation occurs at request time
82
+ - Build times grow linearly with page count (problematic at 10K+ pages)
83
+
84
+ ### 1.5 Incremental Static Regeneration (ISR)
85
+
86
+ ISR combines SSG speed with SSR freshness. Pages are served from cache and regenerated in the
87
+ background at configurable intervals.
88
+
89
+ **Performance profile**:
90
+ - First request after expiry may see SSR-like TTFB (200-600ms)
91
+ - All subsequent requests within the revalidation window get SSG-like performance (20-50ms)
92
+ - Using `stale-while-revalidate`, every request after the first becomes a <50ms CDN hit
93
+ while fresh content is fetched in the background
94
+
95
+ ISR is optimal for e-commerce catalog pages, news sites, and any content that updates hourly
96
+ or daily rather than per-request.
97
+
98
+ ---
99
+
100
+ ## 2. The Hydration Cost Problem
101
+
102
+ ### 2.1 What Is Hydration?
103
+
104
+ Hydration is the process of attaching JavaScript event listeners and component state to
105
+ server-rendered HTML, making the static markup interactive. The browser must:
106
+
107
+ 1. Download the JavaScript bundle (network cost)
108
+ 2. Parse the JavaScript (CPU cost)
109
+ 3. Execute component initialization code (CPU cost)
110
+ 4. Reconcile the server-rendered DOM with React's virtual DOM (CPU cost)
111
+ 5. Attach event listeners (minimal cost)
112
+
113
+ ### 2.2 The "Uncanny Valley" of Web Performance
114
+
115
+ The period between First Contentful Paint and Time to Interactive is the "uncanny valley" --
116
+ users see a fully rendered page but clicks, taps, and scrolls produce no response. This creates
117
+ a worse user experience than a loading spinner because it violates user expectations.
118
+
119
+ **Measured impact**:
120
+ - A typical React application with 200KB of JS (gzipped) takes 1-3 seconds to hydrate on a
121
+ mid-range mobile device (Moto G Power class)
122
+ - During hydration, the main thread is blocked, meaning user interactions are queued
123
+ - INP (Interaction to Next Paint) violations are common: pages must achieve INP under 200ms to
124
+ pass Core Web Vitals, but hydration-blocked interactions can exceed 500ms
125
+ - Only 47% of sites met all Core Web Vitals thresholds in 2025, with LCP being the hardest
126
+ metric to pass (only 62% of mobile pages achieve a "good" LCP score)
127
+
128
+ ### 2.3 Quantifying Hydration Cost
129
+
130
+ Hydration cost scales with:
131
+
132
+ | Factor | Impact |
133
+ |--------|--------|
134
+ | Number of components | Linear: each component runs its initialization logic |
135
+ | Component tree depth | Sub-linear but adds reconciliation overhead |
136
+ | Event listeners | Minimal per-listener, but thousands add up |
137
+ | State initialization | Proportional to computation in `useState`/`useEffect` |
138
+ | Third-party libraries | Often the largest contributor (analytics, A/B testing, ads) |
139
+
140
+ **Rule of thumb**: Every 100KB of JavaScript adds approximately 300-500ms of hydration time on
141
+ a median mobile device. A 500KB bundle (common in e-commerce) can produce 1.5-2.5 seconds of
142
+ main-thread blocking during hydration.
143
+
144
+ ### 2.4 Double Rendering Problem
145
+
146
+ Traditional SSR performs rendering twice:
147
+ 1. Server renders the component tree to HTML (server cost)
148
+ 2. Client re-renders the entire component tree during hydration (client cost)
149
+
150
+ This means the CPU work of rendering is duplicated. The server's rendering work is "thrown away"
151
+ on the client as React reconciles from scratch. This is the fundamental inefficiency that
152
+ streaming SSR, partial hydration, and resumability each attempt to solve.
153
+
154
+ ---
155
+
156
+ ## 3. Streaming SSR
157
+
158
+ ### 3.1 How Streaming SSR Works
159
+
160
+ Instead of waiting for the entire HTML document to be generated, streaming SSR sends HTML to the
161
+ browser incrementally as it is produced. The server begins flushing the `<head>` and initial
162
+ content immediately, while slower data-dependent sections are streamed later.
163
+
164
+ ```
165
+ Traditional SSR timeline:
166
+ Server: [--fetch data--][--render HTML--][--send response--]
167
+ Browser: [--parse--][--paint--][--hydrate--]
168
+ TTFB: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
169
+
170
+ Streaming SSR timeline:
171
+ Server: [--send shell--][--fetch data--][--stream chunks--]
172
+ Browser: [--parse shell--][--paint shell--] [--parse chunks--][--hydrate--]
173
+ TTFB: ~~~~~~~~~~~~~~|
174
+ ```
175
+
176
+ ### 3.2 Performance Benefits
177
+
178
+ **TTFB reduction**: Streaming SSR reduces TTFB from 350-550ms (traditional SSR) to 40-90ms
179
+ in production benchmarks. The static shell ships immediately while data-dependent content
180
+ streams in afterward.
181
+
182
+ **Perceived load time**: Streaming SSR reduces perceived load times by up to 40% compared to
183
+ traditional SSR because users see content progressively rather than staring at a blank page.
184
+
185
+ **Real-world benchmark** (data-heavy dashboard):
186
+ - Unoptimized RSC: TTFB 350-550ms depending on backend latency
187
+ - With progressive streaming: first bytes in 40-90ms, full page painted under 400ms
188
+ - Net improvement: 75-85% reduction in TTFB
189
+
190
+ ### 3.3 React 18+ Streaming Architecture
191
+
192
+ React 18 introduced `renderToPipeableStream` (Node.js) and `renderToReadableStream` (Web
193
+ Streams API) to replace the blocking `renderToString`.
194
+
195
+ Key mechanisms:
196
+ - **Suspense boundaries**: Each `<Suspense>` boundary can stream independently. Content inside
197
+ a Suspense boundary is replaced with a fallback until the server finishes rendering it, then
198
+ the completed HTML is streamed with an inline `<script>` that swaps it in.
199
+ - **Selective hydration**: React 18 can prioritize hydrating components the user is trying to
200
+ interact with, even if other parts of the page are still streaming.
201
+ - **Out-of-order streaming**: Sections can complete and stream in any order; the browser
202
+ inserts them into the correct DOM location regardless of arrival sequence.
203
+
204
+ ### 3.4 Framework Support
205
+
206
+ | Framework | Streaming Support | Implementation |
207
+ |-----------|------------------|----------------|
208
+ | **Next.js App Router** | Built-in | Automatic with `loading.tsx` and Suspense |
209
+ | **Remix / React Router v7** | Built-in | `defer()` + `<Await>` components |
210
+ | **Nuxt 3** | Built-in | Automatic with `<Suspense>` |
211
+ | **SvelteKit** | Built-in | Streaming by default since 2.0 |
212
+ | **Astro** | Built-in | Server islands stream independently |
213
+ | **Angular** | Experimental | Available since Angular 17 |
214
+
215
+ ---
216
+
217
+ ## 4. React Server Components
218
+
219
+ ### 4.1 The RSC Performance Model
220
+
221
+ React Server Components (RSC) execute exclusively on the server and send a serialized
222
+ representation (the "RSC payload" or "Flight payload") to the client. Unlike traditional SSR,
223
+ RSC components never ship their JavaScript to the browser.
224
+
225
+ **Key performance characteristics**:
226
+ - Server Components contribute zero bytes to the client JavaScript bundle
227
+ - Only components marked with `"use client"` ship JS to the browser
228
+ - Data fetching happens on the server, close to the database, avoiding client-server waterfalls
229
+ - The RSC payload is a compact serialized format, typically smaller than equivalent HTML
230
+
231
+ ### 4.2 Bundle Size Impact
232
+
233
+ Real-world measurements show:
234
+ - Up to 62% reduction in JavaScript bundle size when migrating to RSC
235
+ - Initial RSC bundle: 40-50KB (framework runtime + client component code)
236
+ - Compare to traditional React SPA: 150-400KB typical, 500KB+ for large apps
237
+
238
+ **Case study**: An e-commerce company migrating product listing pages to RSC reported a 40%
239
+ improvement in load times and a 15% increase in conversion rates within the first quarter.
240
+
241
+ ### 4.3 RSC Payload and Serialization Cost
242
+
243
+ Crossing a Server-to-Client boundary incurs serialization costs. All props passed from Server
244
+ Components to Client Components must be serialized into the Flight payload.
245
+
246
+ **Optimization strategies**:
247
+ - Pass only the data you need: filter unused properties before passing to client components
248
+ - Pass Server Components as `children` props: the RSC payload includes pre-rendered output,
249
+ which is smaller than raw data objects
250
+ - Avoid serializing large objects: a 50KB JSON blob serialized as RSC props adds ~50KB to
251
+ the Flight payload on every navigation
252
+
253
+ **Server rendering overhead**: Benchmarks show that React rendering on the server adds only a
254
+ small percentage of overhead compared to database + business logic. The true bottleneck at
255
+ scale is almost always database I/O, not React rendering.
256
+
257
+ ### 4.4 When RSC Helps vs. When It Does Not
258
+
259
+ RSC delivers measurable performance gains when:
260
+ - The page has significant static content mixed with interactive elements
261
+ - Data fetching is involved (server-side fetching eliminates client waterfalls)
262
+ - Large dependencies (date libraries, markdown parsers) can stay server-only
263
+
264
+ RSC does NOT help when:
265
+ - The app is almost entirely interactive (most components need `"use client"`)
266
+ - Bundle size is already small
267
+ - No data fetching occurs (static content is better served by SSG)
268
+
269
+ **Critical insight**: Performance benefits from Server Components only appear when they
270
+ actually reduce the client bundle or eliminate data-fetching waterfalls. If an app is a mix
271
+ of Client and Server Components and the bundle size reduction is negligible, streaming and
272
+ Suspense are what deliver the real performance improvement, not RSC alone.
273
+
274
+ ### 4.5 Hidden Costs
275
+
276
+ - **RSC payload duplication**: On client-side navigations, the RSC payload is fetched for
277
+ each route, adding network requests that did not exist in a traditional SPA
278
+ - **Waterfall risk**: Nested Server Components can create sequential data-fetching waterfalls
279
+ on the server if not parallelized with `Promise.all` or similar patterns
280
+ - **Cold starts**: Serverless SSR functions face cold-start penalties of 200-1500ms depending
281
+ on runtime and bundle size
282
+
283
+ ---
284
+
285
+ ## 5. Islands Architecture
286
+
287
+ ### 5.1 Concept
288
+
289
+ Islands Architecture treats a page as a sea of static HTML with discrete "islands" of
290
+ interactive JavaScript. Only the islands are hydrated; the rest remains inert HTML that
291
+ never loads or executes JavaScript.
292
+
293
+ ```
294
+ +------------------------------------------------------------------+
295
+ | Static HTML (no JS) |
296
+ | |
297
+ | +------------------+ +-------------------+ |
298
+ | | Interactive | | Interactive | |
299
+ | | Island (React) | | Island (Svelte) | |
300
+ | | ~15KB JS | | ~8KB JS | |
301
+ | +------------------+ +-------------------+ |
302
+ | |
303
+ | Static HTML (no JS) |
304
+ | |
305
+ | +------------------------------------------+ |
306
+ | | Interactive Island (Vue) ~12KB JS | |
307
+ | +------------------------------------------+ |
308
+ | |
309
+ | Static HTML (no JS) |
310
+ +------------------------------------------------------------------+
311
+ Total JS: ~35KB (vs. 200-400KB for full-page hydration)
312
+ ```
313
+
314
+ ### 5.2 Framework Implementations
315
+
316
+ **Astro**:
317
+ - Achieves the highest Lighthouse scores among tested frameworks: 99.2 in the Enterspeed
318
+ benchmark study
319
+ - Delivers 83% reduction in JavaScript compared to equivalent Next.js/Nuxt.js documentation
320
+ sites
321
+ - Supports mixing React, Vue, Svelte, and Solid components as independent islands
322
+ - Server Islands (Astro 5+): add virtually zero JavaScript (a few hundred bytes of serialized
323
+ props) while streaming independently
324
+
325
+ **Fresh (Deno)**:
326
+ - Zero JS shipped by default; only island components include JavaScript
327
+ - Built on Preact (3KB runtime) for minimal overhead
328
+ - Optimal for content-heavy sites needing selective interactivity
329
+
330
+ **Marko**:
331
+ - Automatic partial hydration: the compiler analyzes which components need client-side JS
332
+ - No manual `client:` directives required
333
+
334
+ ### 5.3 Island JS Budget
335
+
336
+ | Island Runtime | Approximate Size (min+gzip) |
337
+ |---------------|---------------------------|
338
+ | Preact island | 3-5KB |
339
+ | Svelte island | 2-4KB (no runtime) |
340
+ | Solid island | 4-7KB |
341
+ | React island | 30-45KB (runtime included) |
342
+ | Vue island | 20-30KB |
343
+
344
+ For content sites with 2-3 small islands, total JS can stay under 20KB -- an order of
345
+ magnitude less than a typical SPA.
346
+
347
+ ### 5.4 When Islands Win
348
+
349
+ Islands architecture is optimal for:
350
+ - Content-heavy sites (blogs, documentation, marketing pages)
351
+ - Sites with isolated interactive widgets (search bars, comment sections, image carousels)
352
+ - Performance-critical pages where every KB of JS matters
353
+
354
+ Islands are NOT optimal for:
355
+ - Highly interactive applications (dashboards, collaborative tools)
356
+ - Apps where most of the page requires JavaScript
357
+ - Cases requiring shared state across many components (though solutions exist)
358
+
359
+ ---
360
+
361
+ ## 6. Progressive and Lazy Hydration
362
+
363
+ ### 6.1 Progressive Hydration
364
+
365
+ Progressive hydration delays component hydration until specific triggers fire, rather than
366
+ hydrating the entire page at once on load.
367
+
368
+ **Trigger strategies**:
369
+ - **Viewport entry**: Hydrate when the component scrolls into view (IntersectionObserver)
370
+ - **Idle callback**: Hydrate during browser idle time (`requestIdleCallback`)
371
+ - **Interaction**: Hydrate on first user interaction (click, hover, focus)
372
+ - **Media query**: Hydrate only on specific screen sizes
373
+
374
+ **Measured impact**: Real-world testing shows TTI drops of 500-800ms on mobile after replacing
375
+ full hydration with progressive hydration. One e-commerce site reduced landing page hydration
376
+ time by 80% using partial hydration techniques.
377
+
378
+ ### 6.2 React 18 Selective Hydration
379
+
380
+ React 18 implements selective hydration automatically when using Suspense boundaries:
381
+ - Components wrapped in `<Suspense>` are hydrated independently
382
+ - If a user clicks on a not-yet-hydrated Suspense boundary, React prioritizes hydrating
383
+ that section immediately
384
+ - Other sections continue hydrating in the background during idle time
385
+
386
+ This effectively implements progressive hydration at the framework level, making hydration
387
+ more granular and responsive to user input without manual configuration.
388
+
389
+ ### 6.3 Lazy Hydration Patterns
390
+
391
+ ```
392
+ // Conceptual pattern: hydrate on interaction
393
+ function LazyHydrate({ children, on = "idle" }) {
394
+ // Component renders server HTML immediately
395
+ // JavaScript loads and hydrates only on trigger:
396
+ // "idle" -> requestIdleCallback
397
+ // "visible" -> IntersectionObserver
398
+ // "click" -> first interaction
399
+ // "media" -> matchMedia query
400
+ }
401
+ ```
402
+
403
+ **Framework support**:
404
+ - **Astro**: `client:idle`, `client:visible`, `client:media`, `client:only` directives
405
+ - **Next.js**: `dynamic()` with `ssr: false` for client-only, Suspense for selective hydration
406
+ - **Nuxt 3**: `<LazyComponent>` prefix for automatic lazy loading
407
+ - **Angular**: `@defer` blocks with `on viewport`, `on idle`, `on interaction` triggers
408
+
409
+ ### 6.4 Cost/Benefit Analysis
410
+
411
+ | Strategy | TTI Improvement | Complexity | Trade-off |
412
+ |----------|----------------|------------|-----------|
413
+ | Full hydration | Baseline | None | All JS executes upfront |
414
+ | Progressive (idle) | 200-400ms | Low | Slight delay for below-fold interactions |
415
+ | Progressive (visible) | 400-800ms | Low | Components not interactive until visible |
416
+ | Progressive (interaction) | 500-1500ms | Medium | First interaction has ~100ms delay |
417
+ | No hydration (static) | Maximum | None | No interactivity |
418
+
419
+ ---
420
+
421
+ ## 7. Resumability: The Post-Hydration Paradigm
422
+
423
+ ### 7.1 How Resumability Differs from Hydration
424
+
425
+ Traditional hydration re-executes component code on the client to rebuild state and attach
426
+ listeners. Resumability serializes the application state, component boundaries, and listener
427
+ locations into HTML, allowing the client to "resume" exactly where the server left off with
428
+ zero re-execution.
429
+
430
+ ```
431
+ Hydration:
432
+ Server: render -> serialize HTML
433
+ Client: download JS -> parse JS -> execute JS -> reconcile DOM -> attach listeners
434
+ Cost: O(page_complexity)
435
+
436
+ Resumability:
437
+ Server: render -> serialize HTML + state + listener locations
438
+ Client: (nothing on load) -> on interaction: download handler -> execute handler
439
+ Cost: O(interaction_count), amortized per-interaction
440
+ ```
441
+
442
+ ### 7.2 Qwik Performance Benchmarks
443
+
444
+ Qwik, the primary framework implementing resumability:
445
+ - **50-80% faster than React on first load and first interaction**
446
+ - Initial bundle: 15-20KB (vs. React's 40-50KB with RSC, or 150-400KB traditional)
447
+ - 25-40% faster metrics across the board compared to React Server Components
448
+ - The performance gap widens on mobile devices and slower connections
449
+ - Near-instant TTI because there is no hydration step -- the page is interactive immediately
450
+
451
+ ### 7.3 Trade-offs
452
+
453
+ - **Ecosystem maturity**: Qwik's ecosystem is significantly smaller than React's
454
+ - **Developer experience**: Requires learning new patterns (`$()` functions, serialization
455
+ constraints)
456
+ - **Per-interaction cost**: Each first interaction incurs a small lazy-load delay (~50-100ms)
457
+ as the specific handler is downloaded
458
+ - **Serialization constraints**: Not all JavaScript values can be serialized (closures over
459
+ non-serializable state require workarounds)
460
+
461
+ ---
462
+
463
+ ## 8. Edge Rendering
464
+
465
+ ### 8.1 Edge SSR Performance
466
+
467
+ Edge rendering executes SSR logic at CDN edge locations (300+ global PoPs), eliminating
468
+ the round-trip to a centralized origin server.
469
+
470
+ **TTFB benchmarks by deployment model**:
471
+
472
+ | Deployment Model | TTFB (warm) | TTFB (cold) | Global P95 |
473
+ |-----------------|-------------|-------------|------------|
474
+ | SSG + Edge Cache | 20-50ms | 20-50ms | <100ms |
475
+ | Edge Functions (warm) | 37-60ms | 100-300ms | <150ms |
476
+ | Regional Serverless (warm) | 103-154ms | 300-1500ms | <500ms |
477
+ | Traditional SSR (origin) | 200-600ms | 200-600ms | 300-800ms |
478
+
479
+ Edge computing reduces TTFB by 60-80% for global users by eliminating the round-trip to
480
+ a centralized origin server.
481
+
482
+ ### 8.2 Platform Comparison
483
+
484
+ **Cloudflare Workers**:
485
+ - V8 isolate model: lightweight isolates instead of full containers
486
+ - Sub-millisecond cold starts for small workers
487
+ - ~25% performance improvement from V8 garbage collection optimizations (2025)
488
+ - Limitation: no Node.js API compatibility (must use Web APIs or `node_compat` flag)
489
+ - CPU time limit: 10-50ms on free plan, up to 30 seconds on paid plans
490
+
491
+ **Vercel Edge Runtime**:
492
+ - Built on V8 isolates (similar to Cloudflare Workers)
493
+ - Fluid Compute: bytecode caching and predictive instance warming reduce cold starts to
494
+ near-imperceptible levels
495
+ - Tight integration with Next.js App Router and Partial Prerendering
496
+ - Benchmarks show Vercel is 1.2x to 5x faster than Cloudflare for server rendering
497
+ (according to Vercel's own testing; independent verification varies)
498
+
499
+ **Deno Deploy**:
500
+ - V8 isolate model with native TypeScript support
501
+ - Built-in support for Fresh framework's islands architecture
502
+ - Global deployment across 35+ regions
503
+
504
+ ### 8.3 Edge Rendering Constraints
505
+
506
+ Edge functions face real limitations:
507
+ - **Limited compute budget**: Complex rendering or data transformation may exceed CPU limits
508
+ - **No persistent connections**: Cannot maintain database connection pools (must use HTTP-based
509
+ database proxies or edge-compatible databases like PlanetScale, Neon, Turso)
510
+ - **Bundle size limits**: Cloudflare Workers: 10MB (paid), Vercel Edge: 4MB
511
+ - **No filesystem access**: Cannot read files from disk at runtime
512
+ - **Cold starts still exist**: Though much shorter (50-300ms) than traditional serverless
513
+ (300-1500ms)
514
+
515
+ ### 8.4 Partial Prerendering (PPR)
516
+
517
+ Next.js Partial Prerendering combines edge-cached static shells with streaming dynamic content:
518
+
519
+ 1. Static shell is pre-rendered at build time and cached at the edge
520
+ 2. Dynamic "holes" in the shell are filled by streaming SSR at request time
521
+ 3. TTFB reflects CDN latency (20-50ms) rather than server processing time
522
+ 4. Dynamic content streams in after the shell is painted
523
+
524
+ **Benchmark**: PPR moved TTFB from 350-550ms (all data fetched before response) to 40-90ms
525
+ (static shell from edge, data streamed after).
526
+
527
+ ---
528
+
529
+ ## 9. Common Bottlenecks
530
+
531
+ ### 9.1 Full-Page Hydration Cost
532
+
533
+ **Problem**: The entire component tree is hydrated on load, even for components that are
534
+ never interacted with (footers, static content sections, decorative elements).
535
+
536
+ **Impact**: On a page with 500 components, hydration may take 1.5-3 seconds on a median
537
+ mobile device, during which the page appears frozen.
538
+
539
+ **Solution**: Progressive hydration, islands architecture, or RSC to limit hydration scope.
540
+
541
+ ### 9.2 Serialization Overhead
542
+
543
+ **Problem**: SSR requires serializing the rendered output (HTML) and, with RSC, the Flight
544
+ payload. Large data objects passed as props are serialized redundantly.
545
+
546
+ **Impact**: A product listing page passing 200 product objects (each 2KB) adds ~400KB of
547
+ serialized data to the response, increasing transfer time by 200-800ms on 3G connections.
548
+
549
+ **Solution**: Paginate data, filter to only necessary fields, use server-side pagination
550
+ with streaming.
551
+
552
+ ### 9.3 TTFB in Traditional SSR
553
+
554
+ **Problem**: Traditional SSR blocks the response until all data is fetched and the full page
555
+ is rendered. Sequential data-fetching waterfalls compound the delay.
556
+
557
+ **Impact**: A page with 3 sequential API calls (each 100ms) + rendering (100ms) = 400ms TTFB
558
+ minimum before the browser receives any bytes.
559
+
560
+ **Solution**: Streaming SSR, parallel data fetching, or Partial Prerendering.
561
+
562
+ ### 9.4 Layout Thrashing During Hydration
563
+
564
+ **Problem**: Hydration can cause layout shifts if the client-rendered output differs from
565
+ the server-rendered output (hydration mismatches).
566
+
567
+ **Impact**: CLS (Cumulative Layout Shift) violations. Google's threshold is CLS < 0.1;
568
+ hydration mismatches can cause CLS > 0.25.
569
+
570
+ **Solution**: Ensure server and client render identical output. Use `suppressHydrationWarning`
571
+ only as a last resort for intentional differences (timestamps, user-agent-specific content).
572
+
573
+ ### 9.5 Third-Party Script Blocking
574
+
575
+ **Problem**: Third-party scripts (analytics, ads, A/B testing) compete with hydration for
576
+ main-thread time.
577
+
578
+ **Impact**: A single analytics SDK can add 200-500ms to TTI. Multiple third-party scripts
579
+ can push TTI beyond 5 seconds on mobile.
580
+
581
+ **Solution**: Load third-party scripts with `defer` or `async`, use `requestIdleCallback`
582
+ for non-critical initialization, consider server-side analytics (Plausible, Fathom), or
583
+ use Partytown to offload scripts to a web worker.
584
+
585
+ ---
586
+
587
+ ## 10. Anti-Patterns
588
+
589
+ ### 10.1 Hydrating Everything
590
+
591
+ **Pattern**: Using SSR/SSG but then hydrating the entire page, including static content
592
+ that never changes or responds to user interaction.
593
+
594
+ **Cost**: A documentation page with a single search widget hydrates 200+ static components
595
+ just to make the search interactive. This can waste 1-2 seconds of main-thread time.
596
+
597
+ **Fix**: Use islands architecture (Astro) or extract the interactive part into a
598
+ `"use client"` island while keeping the rest as Server Components.
599
+
600
+ ### 10.2 SSR Without Streaming
601
+
602
+ **Pattern**: Using `renderToString` (React) or equivalent blocking SSR methods.
603
+
604
+ **Cost**: TTFB increases linearly with page complexity. A data-heavy page may not send
605
+ its first byte for 500ms+ while the server renders everything.
606
+
607
+ **Fix**: Migrate to `renderToPipeableStream` (React 18+) or equivalent streaming APIs.
608
+ Wrap data-dependent sections in Suspense boundaries.
609
+
610
+ ### 10.3 Blocking Data Fetching in SSR
611
+
612
+ **Pattern**: Sequential `await` calls in server-side data fetching, creating waterfalls.
613
+
614
+ ```
615
+ // Anti-pattern: sequential fetches
616
+ const user = await getUser(id); // 100ms
617
+ const posts = await getPosts(user.id); // 150ms
618
+ const comments = await getComments(); // 100ms
619
+ // Total: 350ms before rendering starts
620
+
621
+ // Fix: parallel fetches where possible
622
+ const [user, comments] = await Promise.all([
623
+ getUser(id), // 100ms
624
+ getComments(), // 100ms
625
+ ]); // Total: 100ms
626
+ const posts = await getPosts(user.id); // 150ms (depends on user)
627
+ // Total: 250ms -- 29% faster
628
+ ```
629
+
630
+ ### 10.4 Over-Serializing Props
631
+
632
+ **Pattern**: Passing entire database objects through Server-to-Client component boundaries.
633
+
634
+ **Cost**: A 50KB user object serialized as props adds 50KB to every RSC payload. On pages
635
+ with multiple such objects, payload sizes balloon.
636
+
637
+ **Fix**: Extract only the fields the client component needs:
638
+ ```
639
+ // Anti-pattern
640
+ <ClientComponent user={fullUserObject} /> // 50KB serialized
641
+
642
+ // Fix
643
+ <ClientComponent name={user.name} avatar={user.avatarUrl} /> // ~100 bytes
644
+ ```
645
+
646
+ ### 10.5 Not Caching SSR Output
647
+
648
+ **Pattern**: Re-rendering identical pages on every request without any caching layer.
649
+
650
+ **Cost**: A product page that changes once per hour is rendered 10,000 times between
651
+ updates, wasting server CPU and keeping TTFB at 200-600ms for all users.
652
+
653
+ **Fix**: Use ISR with appropriate revalidation intervals, CDN caching with
654
+ `stale-while-revalidate`, or full-page caching with cache invalidation webhooks.
655
+
656
+ ### 10.6 Importing Heavy Libraries in Client Components
657
+
658
+ **Pattern**: Importing large libraries (moment.js: 72KB, lodash full: 72KB) in client
659
+ components when only a few functions are needed.
660
+
661
+ **Cost**: Every KB of client JavaScript adds hydration time. These libraries are parsed
662
+ and executed during hydration even if they are only used for a single function.
663
+
664
+ **Fix**: Use tree-shakable alternatives (date-fns: 2-5KB per function, lodash-es with
665
+ specific imports), or move the computation to a Server Component.
666
+
667
+ ---
668
+
669
+ ## 11. Before/After Case Studies
670
+
671
+ ### 11.1 E-Commerce Product Listing (RSC Migration)
672
+
673
+ | Metric | Before (CSR) | After (RSC + Streaming) | Improvement |
674
+ |--------|-------------|------------------------|-------------|
675
+ | JS Bundle | 380KB | 145KB | -62% |
676
+ | TTFB | 450ms | 120ms | -73% |
677
+ | LCP | 2.9s | 1.8s | -38% |
678
+ | TTI | 4.2s | 2.1s | -50% |
679
+ | Conversion Rate | Baseline | +15% | +15% |
680
+
681
+ Source: Production migration case study, e-commerce platform (2024).
682
+
683
+ ### 11.2 Data Dashboard (Streaming SSR Optimization)
684
+
685
+ | Metric | Before (Traditional SSR) | After (Streaming SSR + PPR) | Improvement |
686
+ |--------|-------------------------|---------------------------|-------------|
687
+ | TTFB | 350-550ms | 40-90ms | -80% |
688
+ | Full Page Paint | 1.2s | 400ms | -67% |
689
+ | Perceived Load Time | 1.2s | 400ms | -67% |
690
+
691
+ Source: Internal benchmark on data-heavy dashboard application.
692
+
693
+ ### 11.3 Documentation Site (Islands Migration)
694
+
695
+ | Metric | Before (Next.js SPA) | After (Astro Islands) | Improvement |
696
+ |--------|---------------------|----------------------|-------------|
697
+ | JS Shipped | 185KB | 32KB | -83% |
698
+ | Lighthouse Score | 72 | 99 | +38% |
699
+ | TTI | 3.1s | 0.8s | -74% |
700
+ | LCP | 1.8s | 0.6s | -67% |
701
+
702
+ Source: Astro framework benchmarks and Enterspeed comparative study.
703
+
704
+ ### 11.4 Next.js TTFB Optimization (Catch Metrics)
705
+
706
+ | Metric | Before | After | Improvement |
707
+ |--------|--------|-------|-------------|
708
+ | TTFB | 800ms | <100ms | -87% |
709
+ | Server Render Time | 600ms | 50ms | -92% |
710
+
711
+ Techniques applied: streaming SSR, edge caching, database query optimization,
712
+ `stale-while-revalidate` caching strategy.
713
+
714
+ ### 11.5 Mobile Performance (Progressive Hydration)
715
+
716
+ | Metric | Before (Full Hydration) | After (Progressive) | Improvement |
717
+ |--------|------------------------|---------------------|-------------|
718
+ | TTI (mobile) | 4.5s | 3.7-4.0s | 500-800ms faster |
719
+ | TBT | 1200ms | 400ms | -67% |
720
+ | Hydration Time | 2.0s | 0.4s | -80% |
721
+
722
+ Source: Real-world testing data from progressive hydration implementations.
723
+
724
+ ---
725
+
726
+ ## 12. Decision Tree: Should I Use SSR?
727
+
728
+ ```
729
+ START: What type of application are you building?
730
+ |
731
+ +---> Content site (blog, docs, marketing)?
732
+ | |
733
+ | +---> Content changes rarely (daily or less)?
734
+ | | |
735
+ | | YES --> Use SSG
736
+ | | (Best: Astro, Next.js static export, Hugo)
737
+ | | Expected: TTFB <50ms, LCP <1s, Lighthouse 95+
738
+ | |
739
+ | +---> Content changes frequently but not per-user?
740
+ | | |
741
+ | | YES --> Use ISR (revalidate every N seconds)
742
+ | | (Best: Next.js ISR, Nuxt ISR)
743
+ | | Expected: TTFB <50ms (cached), LCP <1.2s
744
+ | |
745
+ | +---> Needs some interactivity (search, comments)?
746
+ | |
747
+ | YES --> Use Islands Architecture
748
+ | (Best: Astro, Fresh)
749
+ | Expected: JS <30KB, TTI <1s
750
+ |
751
+ +---> E-commerce / product pages?
752
+ | |
753
+ | +---> Catalog pages (many products, infrequent updates)?
754
+ | | |
755
+ | | YES --> Use ISR + Edge caching
756
+ | | Expected: TTFB <50ms, LCP <1.5s
757
+ | |
758
+ | +---> Product detail pages (personalized pricing, inventory)?
759
+ | | |
760
+ | | YES --> Use Streaming SSR or PPR
761
+ | | (Best: Next.js App Router, Remix)
762
+ | | Expected: TTFB <100ms (shell), LCP <2s
763
+ | |
764
+ | +---> Cart / checkout (highly interactive)?
765
+ | |
766
+ | YES --> Use SSR for initial load + client-side for interactions
767
+ | Expected: LCP <2s, TTI <3s
768
+ |
769
+ +---> Dashboard / SaaS application?
770
+ | |
771
+ | +---> Behind authentication (SEO irrelevant)?
772
+ | | |
773
+ | | YES --> Consider CSR (SPA)
774
+ | | (Best: Vite + React/Vue, or Next.js with client components)
775
+ | | Expected: Fast transitions after initial load
776
+ | |
777
+ | +---> Needs fast initial load + real-time data?
778
+ | | |
779
+ | | YES --> Use Streaming SSR
780
+ | | (Best: Next.js App Router, Remix)
781
+ | | Expected: TTFB <100ms (shell), full data <500ms
782
+ | |
783
+ | +---> Data-heavy with many widgets?
784
+ | |
785
+ | YES --> Use Streaming SSR + Progressive Hydration
786
+ | Expected: TTFB <90ms, widgets load progressively
787
+ |
788
+ +---> Real-time / collaborative app?
789
+ | |
790
+ | YES --> Use CSR with WebSocket/SSE
791
+ | SSR adds complexity with minimal benefit for real-time UIs
792
+ | (Best: Vite + React/Vue/Solid)
793
+ |
794
+ +---> Mobile-first / performance-critical?
795
+ |
796
+ +---> Target audience on slow devices/networks?
797
+ | |
798
+ | YES --> Minimize JS at all costs
799
+ | Use Islands (Astro) or Resumability (Qwik)
800
+ | Expected: TTI <2s on 3G, JS <50KB
801
+ |
802
+ +---> Need framework ecosystem (React)?
803
+ |
804
+ YES --> Use RSC + Streaming SSR + Progressive Hydration
805
+ Expected: LCP <2.5s, TTI <3.5s on mobile
806
+ ```
807
+
808
+ ### Quick Decision Heuristic
809
+
810
+ | If your priority is... | Choose... | Because... |
811
+ |------------------------|-----------|------------|
812
+ | Maximum performance, minimal JS | Astro Islands | 83% less JS, Lighthouse 99+ |
813
+ | SEO + dynamic content | Streaming SSR (Next.js/Remix) | Fast TTFB + crawlable HTML |
814
+ | Static content at scale | SSG or ISR | CDN-speed delivery, zero server cost |
815
+ | React ecosystem + performance | RSC + Streaming | 62% bundle reduction, streaming TTFB |
816
+ | Absolute fastest TTI | Qwik (resumability) | 50-80% faster first load than React |
817
+ | Global audience, low latency | Edge SSR + PPR | 60-80% TTFB reduction for global users |
818
+ | Internal tool, SEO irrelevant | CSR (Vite SPA) | Simplest architecture, fast dev cycle |
819
+
820
+ ---
821
+
822
+ ## 13. Implementation Checklist
823
+
824
+ ### SSR Performance Audit
825
+
826
+ - [ ] **Measure baseline**: Record TTFB, FCP, LCP, TTI, TBT, INP, CLS for current implementation
827
+ - [ ] **Profile hydration**: Use React DevTools Profiler or Chrome Performance tab to measure
828
+ hydration duration and identify slow components
829
+ - [ ] **Audit JS bundle**: Use `next/bundle-analyzer`, `webpack-bundle-analyzer`, or `source-map-explorer`
830
+ to identify oversized dependencies
831
+ - [ ] **Check for sequential data fetching**: Grep for sequential `await` calls in server-side
832
+ data fetching; parallelize with `Promise.all` where possible
833
+ - [ ] **Verify streaming**: Confirm the application uses streaming SSR (`renderToPipeableStream`)
834
+ rather than blocking `renderToString`
835
+
836
+ ### Quick Wins (Each saves 100-500ms)
837
+
838
+ - [ ] **Add Suspense boundaries**: Wrap data-dependent sections to enable streaming and selective
839
+ hydration
840
+ - [ ] **Lazy-load below-fold components**: Use `dynamic()` (Next.js) or `React.lazy()` with
841
+ Suspense for components not visible on initial viewport
842
+ - [ ] **Move heavy libraries server-side**: Libraries used only for rendering (markdown, date
843
+ formatting, syntax highlighting) belong in Server Components
844
+ - [ ] **Optimize images**: Use `<Image>` component (Next.js) or `<picture>` with `srcset` for
845
+ responsive images; this alone can improve LCP by 200-500ms
846
+ - [ ] **Defer third-party scripts**: Use `next/script` with `strategy="lazyOnload"` or manual
847
+ `defer`/`async` attributes
848
+
849
+ ### Advanced Optimizations
850
+
851
+ - [ ] **Implement PPR**: Use Next.js Partial Prerendering to serve static shells from edge cache
852
+ while streaming dynamic content
853
+ - [ ] **Edge deployment**: Deploy to Cloudflare Workers, Vercel Edge, or Deno Deploy for
854
+ 60-80% TTFB reduction for global users
855
+ - [ ] **ISR for semi-static pages**: Configure revalidation intervals for pages that change
856
+ infrequently (product catalogs, blog posts)
857
+ - [ ] **Database proximity**: Ensure the database is in the same region as the SSR server;
858
+ 50ms of network latency per query compounds rapidly
859
+ - [ ] **Connection pooling**: Use connection poolers (PgBouncer, PlanetScale connection pooling)
860
+ to avoid cold-connection overhead on serverless
861
+
862
+ ### Monitoring
863
+
864
+ - [ ] **Set up Real User Monitoring (RUM)**: Track Core Web Vitals in production with
865
+ `web-vitals` library, Vercel Analytics, or DebugBear
866
+ - [ ] **Alert on regressions**: Set thresholds for TTFB (<800ms), LCP (<2.5s), INP (<200ms)
867
+ - [ ] **Track hydration time**: Custom performance marks around hydration to monitor drift
868
+ - [ ] **Monitor RSC payload size**: Track Flight payload size per route to catch prop bloat early
869
+
870
+ ---
871
+
872
+ ## 14. Sources
873
+
874
+ ### Performance Data and Benchmarks
875
+ - [Edge vs SSR vs SSG: 2025 Performance Benchmarks & TTFB Data](https://medium.com/better-dev-nextjs-react/edge-vs-ssr-vs-ssg-2025-performance-benchmarks-ttfb-data-meta-description-7b508c572b5f) - Melvin Prince, Better Dev
876
+ - [React Server Components: Do They Really Improve Performance?](https://www.developerway.com/posts/react-server-components-performance) - Nadia Makarevich, Developer Way
877
+ - [Intro to Performance of React Server Components](https://calendar.perfplanet.com/2025/intro-to-performance-of-react-server-components/) - Web Performance Calendar, 2025
878
+ - [The Hidden Performance Costs of React Server Components](https://dev.to/rbobr/the-hidden-performance-costs-of-react-server-components-248f) - DEV Community
879
+ - [Unpacking Cloudflare Workers CPU Performance Benchmarks](https://blog.cloudflare.com/unpacking-cloudflare-workers-cpu-performance-benchmarks/) - Cloudflare Blog
880
+
881
+ ### SSR and Streaming
882
+ - [Modern SSR 2025: Ultrafast Web Performance](https://blog.madrigan.com/en/blog/202603061451/) - Madrigan Blog
883
+ - [SSR 2025: Selective Hydration, Streaming, and Edge](https://blog.madrigan.com/en/blog/202512041544/) - Madrigan Blog
884
+ - [Revisiting HTML Streaming for Modern Web Performance](https://calendar.perfplanet.com/2025/revisiting-html-streaming-for-modern-web-performance/) - Web Performance Calendar
885
+ - [Server-Side Rendering Evolved: Unlocking Faster TTFB and TTI with Streaming SSR](https://medium.com/cstech/server-side-rendering-evolved-unlocking-faster-ttfb-and-tti-with-streaming-ssr-800735e37bad) - CSTech
886
+ - [The Ultimate Guide to Improving Next.js TTFB Slowness](https://www.catchmetrics.io/blog/the-ultimate-guide-to-improving-nextjs-ttfb-slowness-from-800ms-to-less100ms) - Catch Metrics
887
+ - [Optimizing Nuxt SSR Performance](https://www.debugbear.com/blog/nuxt-ssr-performance) - DebugBear
888
+
889
+ ### Hydration and Islands
890
+ - [Improving Front-end Performance through Modular Rendering and Adaptive Hydration](https://arxiv.org/html/2504.03884v1) - arXiv (academic paper)
891
+ - [Progressive Hydration Explained](https://devtechinsights.com/progressive-hydration-web-performance-2025/) - Dev Tech Insights
892
+ - [Progressive Hydration Pattern](https://www.patterns.dev/react/progressive-hydration/) - Patterns.dev
893
+ - [Islands Architecture Pattern](https://www.patterns.dev/vanilla/islands-architecture/) - Patterns.dev
894
+ - [Astro Islands Architecture](https://docs.astro.build/en/concepts/islands/) - Astro Docs
895
+ - [Why Islands Architecture Is the Future](https://dev.to/siva_upadhyayula_f2e09ded/why-islands-architecture-is-the-future-of-high-performance-frontend-apps-3cf5) - DEV Community
896
+
897
+ ### Framework Comparisons
898
+ - [Qwik vs React vs SolidJS: The Future of Web Performance](https://www.javacodegeeks.com/2025/06/qwik-vs-react-vs-solidjs-the-future-of-web-performance.html) - Java Code Geeks
899
+ - [Next.js vs Qwik: Who Wins the Performance Race in 2025?](https://dev.to/hamzakhan/nextjs-vs-qwik-who-wins-the-performance-race-in-2025-21m9) - DEV Community
900
+ - [Angular vs Qwik vs SolidJS in 2025](https://metadesignsolutions.com/angular-vs-qwik-vs-solidjs-in-2025-the-speed-dx-comparison-resumability-ssr-hydration-techniques/) - Meta Design Solutions
901
+ - [CSR vs SSR vs SSG vs ISR Comparison](https://hashbyt.com/blog/csr-vs-ssr-vs-ssg-vs-isr) - Hashbyt
902
+ - [How to Choose the Best Rendering Strategy](https://vercel.com/blog/how-to-choose-the-best-rendering-strategy-for-your-app) - Vercel Blog
903
+
904
+ ### Core Web Vitals
905
+ - [Core Web Vitals](https://web.dev/articles/vitals) - web.dev
906
+ - [Optimize TTFB](https://web.dev/articles/optimize-ttfb) - web.dev
907
+ - [The Most Effective Ways to Improve Core Web Vitals](https://web.dev/articles/top-cwv) - web.dev
908
+ - [Why React Server Components Matter: Production Performance Insights](https://blogs.perficient.com/2025/12/10/why-react-server-components-matter-production-performance-insights/) - Perficient
909
+
910
+ ### RSC Optimization
911
+ - [How to Optimize RSC Payload Size](https://vercel.com/kb/guide/how-to-optimize-rsc-payload-size) - Vercel Knowledge Base
912
+ - [The Forensics of React Server Components](https://www.smashingmagazine.com/2024/05/forensics-react-server-components/) - Smashing Magazine
913
+ - [Optimizing Next.js Performance: LCP, Render Delay & Hydration](https://www.iamtk.co/optimizing-nextjs-performance-lcp-render-delay-hydration) - TK
914
+
915
+ ### Edge and Platform
916
+ - [Cloudflare vs Vercel vs Netlify: Edge Performance 2026](https://dev.to/dataformathub/cloudflare-vs-vercel-vs-netlify-the-truth-about-edge-performance-2026-50h0) - DEV Community
917
+ - [Vercel vs Cloudflare: Edge Deployment Deep Dive](https://sparkco.ai/blog/vercel-vs-cloudflare-edge-deployment-deep-dive) - SparkCo
918
+ - [Are You Measuring What Matters? A Fresh Look at TTFB](https://blog.cloudflare.com/ttfb-is-not-what-it-used-to-be/) - Cloudflare Blog