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:
- Install
@tanstack/react-query.
- Create a
QueryProvider component and wrap it around the app in Providers.tsx.
- Define mutation keys for authentication (
auth/register, auth/login).
- Implement
useRegisterMutation hook that calls the API client.
- Implement
useLoginMutation hook that calls the API client.
- Ensure error handling and success responses are normalized.
- 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).