Skip to content

FRONTEND: Setup TanStack React Query Provider with Auth Mutations #312

@yusuftomilola

Description

@yusuftomilola

Description:
We need to integrate TanStack React Query into the frontend application for data fetching and mutations. The provider should be set up at the root level of the Next.js 15 app, and authentication-related mutation hooks (register and login) should be implemented. Mutation keys should also be standardized for consistent cache management.


Tasks:

  1. Install @tanstack/react-query.
  2. Create a QueryProvider component and wrap it around the app in Providers.tsx.
  3. Define mutation keys for authentication (auth/register, auth/login).
  4. Implement useRegisterMutation hook that calls the API client.
  5. Implement useLoginMutation hook that calls the API client.
  6. Ensure error handling and success responses are normalized.
  7. Add TypeScript typings for mutation inputs and outputs.

Acceptance Criteria:

  • React Query is set up globally and available throughout the app.
  • useRegisterMutation exists and accepts user credentials → returns success/error states.
  • useLoginMutation exists and accepts login credentials → returns success/error states.
  • Mutation keys are centralized in lib/query/keys.ts.
  • Strong TypeScript typings for all mutations.
  • Query Devtools can be easily enabled for debugging (optional in dev).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions