Can we pass props through middleware
Unanswered
shaurya#007 posted this in #help-forum
![Avatar](https://cdn.discordapp.com/avatars/774523617190871070/9f199c1f7b08d0e3759640c80037efad.webp?size=256)
shaurya#007OP
I am authenticating uses in middleware using jwt , can i pass user data to routes after authentication ?
19 Replies
![Avatar](https://cdn.discordapp.com/embed/avatars/2.png)
Kawakawa
What data are you trying to pass to the user?
As you can't with middleware directly pass data to other parts of the application.
![Avatar](https://cdn.discordapp.com/avatars/774523617190871070/9f199c1f7b08d0e3759640c80037efad.webp?size=256)
shaurya#007OP
Ok, actually I am learning next js. I want to implement role based authentication.
Can you suggest some methods.
I tried with nextAuth but the package is depreciated.
Can you suggest some methods.
I tried with nextAuth but the package is depreciated.
I want to extract user id form jwt, fetch user data with that and then provide the data to routes
![Avatar](https://cdn.discordapp.com/embed/avatars/2.png)
Kawakawa
What data are you fetching, though
Is it a large object?
![Avatar](https://cdn.discordapp.com/avatars/774523617190871070/9f199c1f7b08d0e3759640c80037efad.webp?size=256)
shaurya#007OP
No, it is a single JSON object .
I am fetching it from a mongo server
![Avatar](https://cdn.discordapp.com/embed/avatars/2.png)
Kawakawa
What is the data??! 😂
Is it their profile? Is it their role stuff?
![Avatar](https://cdn.discordapp.com/avatars/774523617190871070/9f199c1f7b08d0e3759640c80037efad.webp?size=256)
shaurya#007OP
Yes
![Avatar](https://cdn.discordapp.com/embed/avatars/2.png)
Kawakawa
"I tried with nextAuth but the package is depreciated."That is very much not the case, what do you mean it's deprecated?
![Avatar](https://cdn.discordapp.com/avatars/774523617190871070/9f199c1f7b08d0e3759640c80037efad.webp?size=256)
shaurya#007OP
![Image](https://cdn.discordapp.com/attachments/1130929355544088686/1130933301155213382/3a5a23d4-ff2c-4e9e-bd25-a6b9fec4b8ef.jpg)
![Avatar](https://cdn.discordapp.com/embed/avatars/2.png)
Kawakawa
That package name doesn't look right. Check the usage on the official next-auth webpage: https://next-auth.js.org/
![Avatar](https://cdn.discordapp.com/avatars/774523617190871070/9f199c1f7b08d0e3759640c80037efad.webp?size=256)
shaurya#007OP
I did checked that
![Image](https://cdn.discordapp.com/attachments/1130929355544088686/1130934454941134879/rn_image_picker_lib_temp_9b98e885-81f0-4b89-a2ee-0a6fac89cad0.jpg)
![Avatar](https://cdn.discordapp.com/embed/avatars/2.png)
Kawakawa
No, check how you're using the package.
![Avatar](https://cdn.discordapp.com/avatars/774523617190871070/9f199c1f7b08d0e3759640c80037efad.webp?size=256)
shaurya#007OP
It is working with next-auth version 4.22.1
I am new to next, is it a good framework for backend? Or I should stick with express
For backend