Skip to content

Issue #95: Frontend — TanStack Query Provider & Root App Layout #248

@wumibals

Description

@wumibals

Labels: frontend setup providers
Area: frontend/app/providers.tsx, frontend/app/layout.tsx
Difficulty: Intermediate

Description

TanStack Query requires a QueryClientProvider wrapping the app. Since Next.js 14 App Router server components cannot use React context directly, the provider must be a client component. The root layout.tsx also sets up global fonts, metadata, and the provider tree.

Acceptance Criteria

  • Create frontend/app/providers.tsx as a "use client" component:
    • Instantiates QueryClient with defaultOptions: { queries: { staleTime: 60 * 1000, retry: 1 } }
    • Wraps children in <QueryClientProvider client={queryClient}> and <ReactQueryDevtools initialIsOpen={false} /> (dev only)
    • Uses useState to ensure QueryClient is created once per component lifetime
  • Create frontend/app/layout.tsx as a server component:
    • Sets <html lang="en"> with Geist Sans and Geist Mono variable fonts from next/font/google
    • Exports metadata: Metadata reading from DEFAULT_SEO in @/lib/constants — sets title, description, keywords, openGraph, twitter card meta
    • Renders <Providers>{children}</Providers> inside <body>
    • Adds suppressHydrationWarning on <body>
  • Fully typed TypeScript; no any

Technical Notes

  • Creating QueryClient inside useState (not at module level) prevents state sharing across requests in SSR
  • ReactQueryDevtools must be conditional on process.env.NODE_ENV === "development" to keep the production bundle lean

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions