---
title: "Comment by Ahmad Yousif on \"Authentication & Refresh token flow with Nextjs, Typescript, React Query and axios interceptors.\" | Hashnode"
description: "I would do it slightly differently, I would send the rT in a cookie instead of sending it in the response , and in the frontend I resend this cookie on every re"
url: "https://hashnode.com/posts/authentication-refresh-token-flow-with-nextjs-typescript-react-query-and-axios-interceptors/6371d17cfb40eef9d39b7930/comment/63726a85da4b9943800c6309"
---

[Discussion](https://hashnode.com/posts/authentication-refresh-token-flow-with-nextjs-typescript-react-query-and-axios-interceptors/6371d17cfb40eef9d39b7930)

Comment [Authentication & Refresh token flow with Nextjs, Typescript, React Query and axios interceptors.](https://hashnode.com/posts/authentication-refresh-token-flow-with-nextjs-typescript-react-query-and-axios-interceptors/6371d17cfb40eef9d39b7930)

[Ahmad Yousif](https://hashnode.com/@Jo89)

[Nov 14, 2022](https://hashnode.com/posts/authentication-refresh-token-flow-with-nextjs-typescript-react-query-and-axios-interceptors/6371d17cfb40eef9d39b7930/comment/63726a85da4b9943800c6309)

I would do it slightly differently, I would send the rT in a cookie instead of sending it in the response , and in the frontend I resend this cookie on every request for protected route back to the backend and compare it's value with the original rT sent upon authentication which would be stored in the db, and maybe not storing the tokens in the local storage but rather in the memory.

[K Srinivas Rao](https://hashnode.com/@srini53168)

[Nov 15, 2022](https://hashnode.com/posts/authentication-refresh-token-flow-with-nextjs-typescript-react-query-and-axios-interceptors/6371d17cfb40eef9d39b7930/comment/63726a85da4b9943800c6309#reply-637323c794b18c4621bda14b)

Ah, yes.. Great suggestion... It's never a good idea to store the tokens on frontend. But I wanted to explain only the frontend side of the authentication in a visual manner, that's why I went with it. I'll explore the full stack side of it another day in a more secure way.
