Best Practices for Nuxt 3 + JWT + Pinia + TanStack Query Integration
Hi everyone! I need some help with organizing a Nuxt 3 project that uses JWT, Pinia, and TanStack Query.
My current setup:
I have a few questions:
My current setup:
- On the login page, I send a request through TanStack Query with the entered phone number and password.
- The received tokens (access and refresh) are encrypted and stored in cookies via Server Routes, and also saved in Pinia.
I have a few questions:
- Should I be using Pinia and TanStack Query for this?
- Would it be better to send the phone number and password directly to Server Routes, make a secure request to the backend from there, encrypt the tokens, and store them in cookies? Then, use middleware to check route protection and user login status by making requests to Server Routes.
- I'm also considering adding an extra request to Server Routes in useCustomFetch to verify login status and refresh tokens if needed. I'm planning to handle 401 errors and logouts in Server Routes as well.