Skip to content
项目

KevinVandy/react-data-fetching

在 GitHub 查看

关于

使用不同的 React 框架多次构建同一个应用,以便在同等条件下进行比较。

网站与应用开发

这些数字如何统计

实测星标增长

24小时
0
7天
0
15天
0
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

React Data Fetching

This repository demonstrates the four main data-fetching strategies in modern React applications: Client-Side Rendering (CSR), Static Site Generation (SSG), Server-Side Rendering (SSR), and Streaming with React Server Components. Each approach is implemented across multiple frameworks to show real-world patterns and trade-offs.

Table of Contents

Client-Side Rendering (CSR/SPAs)

Static Site Generation (SSG)

Server-Side Rendering (SSR)

HTML Streaming (RSC / Astro Server Islands)

Understanding Data-Fetching Strategies

Each directory contains a README explaining the core concepts, pros and cons, and use cases:

  • apps/1-csr/ - Client-Side Rendering: JavaScript fetches data in the browser
  • apps/2-ssg/ - Static Site Generation: Pages built at build time with data pre-fetched
  • apps/3-ssr/ - Server-Side Rendering: HTML generated on server per request
  • apps/4-streaming/ - Streaming: Progressive page delivery with React Server Components

Frameworks Covered

This repository explores data fetching across multiple meta-frameworks and libraries:

  • React Router - Client-side and server-side routing
  • Next.js - Full-stack React framework with SSG, SSR, and RSC
  • Astro - Multi-framework static site generator with server rendering
  • TanStack Router - Type-safe routing with built-in data loading
  • TanStack Start - Full-stack React framework built on TanStack Router
  • SvelteKit - bonus Full-stack Svelte framework for comparison

Getting Started

  1. Install dependencies: pnpm install
  2. Start the backend: pnpm serve (runs json-server on port 3300)
  3. Run any example app using the commands listed above
  4. Each app fetches data from the same API to demonstrate different approaches

The examples progress from basic patterns to more advanced implementations, showing how each strategy evolves with different tools and frameworks. TanStack Query (React Query) is heavily featured throughout, demonstrating how this powerful data-fetching library integrates with various meta-frameworks - from pure client-side apps to server-rendered applications with hydration, and even alongside React Server Components for optimal user experiences.

探索相关项目

加载中…