reactfire icon indicating copy to clipboard operation
reactfire copied to clipboard

Spike: Next.js / React Server Components usage guide

Open tyler-reitz opened this issue 5 months ago • 1 comments

reactfire works with Next.js but the full SSR/RSC story needs exploration before we can write authoritative guidance. Known pieces:

Solved (client-side patterns):

  • Context providers need 'use client' for App Router
  • Browser-only SDKs (Analytics, etc.) also need ssr: false via next/dynamic to prevent SSR initialization — see #530

Needs exploration:

  • How to use Firestore with React Server Components, including serialization constraints (Firestore objects can't cross the RSC boundary as-is)
  • Reference: https://firebase.blog/posts/2026/06/firestore-serialization-react
  • General guidance for which reactfire hooks are RSC-compatible vs. client-only

Outcome: a "Using reactfire with Next.js / RSC" section in docs covering both the simple 'use client' pattern and the Firestore SSR serialization approach.

Related: #530, #334

tyler-reitz avatar Jun 26 '26 19:06 tyler-reitz

The guide should draw a hard boundary between ReactFire's client hooks and server-side data access rather than implying the hooks can gradually become RSC-compatible. A useful example would fetch with the appropriate server Firebase SDK, convert Firestore values into an explicitly serializable DTO, and pass that into a small 'use client' component where ReactFire resumes live updates. Tests or examples should include Timestamp, GeoPoint, DocumentReference, and pending auth state, since those are the places a simple JSON spread tends to fail across the RSC boundary.

hiSandog avatar Jul 10 '26 02:07 hiSandog