Skip to main content
The NCT Hub platform uses a layered approach to data fetching, choosing the right strategy based on use case, caching requirements, and user experience needs. This ensures optimal performance for club management operations, real-time features, and member interactions.

Strategy Preference Order

Choose the earliest applicable strategy:
  1. Pure Server Component (RSC) - Read-only, cacheable, SEO-critical data
  2. Server Action - Mutations returning updated state to RSC
  3. RSC + Client Hydration - When background refresh needed
  4. React Query (Client-Side) - Interactive, rapidly changing state
  5. Realtime Subscriptions - Live updates materially improve UX

1. Pure Server Component (RSC)

When to Use

Best For:
  • Initial page load data
  • SEO-critical content
  • Rarely changing data
  • Read-only operations
  • Database queries that don’t need real-time updates
Not For:
  • Interactive forms
  • Frequent updates
  • Client-side state
  • Real-time data

Implementation

Caching Strategy

Loading States

Error Handling

2. Server Actions

When to Use

Best For:
  • Form submissions
  • Mutations with server-side validation
  • Operations requiring auth checks
  • Redirects after mutations
  • Progressive enhancement
Not For:
  • Read operations (use RSC instead)
  • Complex client-side state management
  • Real-time updates

Implementation

Client Usage

3. RSC + Client Hydration

When to Use

Best For:
  • Initial server render with client updates
  • Data that changes frequently
  • Combining SEO with interactivity
  • Background refresh patterns

Implementation

4. React Query (Client-Side)

When to Use

Best For:
  • Interactive dashboards
  • Rapidly changing data
  • Complex client-side state
  • Optimistic updates
  • Automatic background refetching
Not For:
  • SEO-critical content
  • Initial page load (prefer RSC)

Implementation with tRPC

Query Key Conventions

Use stable array query keys:

Optimistic Updates

Cache Invalidation

5. Realtime Subscriptions

When to Use

Best For:
  • Collaborative features
  • Chat applications
  • Live dashboards
  • Multiplayer features
  • Notification systems
Not For:
  • Infrequent updates
  • Static content
  • SEO-critical data

Implementation

React Query Guidelines

Query Configuration

Prefetching

Parallel Queries

Dependent Queries

Decision Matrix

Best Practices

✅ DO

  1. Start with RSC
  2. Use specific query keys
  3. Set appropriate staleTime
  4. Implement optimistic updates for better UX
  5. Invalidate narrowly

❌ DON’T

  1. Don’t use client fetching for SEO content
  2. Don’t skip staleTime
  3. Don’t invalidate globally
  4. Don’t use Realtime for infrequent updates