Next.js Discord

Discord Forum

Can we pass props through middleware

Unanswered
shaurya#007 posted this in #help-forum
Open in Discord
I am authenticating uses in middleware using jwt , can i pass user data to routes after authentication ?

19 Replies

As you can't with middleware directly pass data to other parts of the application.
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.
I want to extract user id form jwt, fetch user data with that and then provide the data to routes
Is it a large object?
No, it is a single JSON object .
I am fetching it from a mongo server
@shaurya#007 No, it is a single JSON object .
Kawakawa
What is the data??! 😂
Is it their profile? Is it their role stuff?
Yes
Kawakawa
"I tried with nextAuth but the package is depreciated."
That is very much not the case, what do you mean it's deprecated?
Kawakawa
That package name doesn't look right. Check the usage on the official next-auth webpage: https://next-auth.js.org/
@Kawakawa That package name doesn't look right. Check the usage on the official next-auth webpage: https://next-auth.js.org/
I did checked that
Kawakawa
No, check how you're using the package.
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