Auth.js (v5) + i18n in Next14
Answered
Patagonian Sheepdog posted this in #help-forum
Patagonian SheepdogOP
[Sorry for my English, I used google translate]
Good morning,
I'm trying to understand how Next works and I admit I have some problems.
I followed a tutorial to try to implement AuthJS (v5) with the CredentialsProvider. From there, I added middleware to manage my redirects.
The problem is that I would like to add a translation system on top, but there is no way to find it other than with /[locale]/...
And this system asks me for another middleware and I have absolutely no idea how to do that on top.
The project is mounted on:
-NextJS 14
- Next-Auth 5 beta 15
- Prisma
I come out of React having always created my authentications by hand in a way that is not very optimal, but functional. This time, I would like to have a clean and optimized system. But I admit I don't know if I did the right thing...
Do you have any idea how to handle this?
middleware.ts : https://pastebin.com/N33s1QLs
auth.config.ts : https://pastebin.com/x4NfngGi
auth.ts : https://pastebin.com/LfBcBu6S
Good morning,
I'm trying to understand how Next works and I admit I have some problems.
I followed a tutorial to try to implement AuthJS (v5) with the CredentialsProvider. From there, I added middleware to manage my redirects.
The problem is that I would like to add a translation system on top, but there is no way to find it other than with /[locale]/...
And this system asks me for another middleware and I have absolutely no idea how to do that on top.
The project is mounted on:
-NextJS 14
- Next-Auth 5 beta 15
- Prisma
I come out of React having always created my authentications by hand in a way that is not very optimal, but functional. This time, I would like to have a clean and optimized system. But I admit I don't know if I did the right thing...
Do you have any idea how to handle this?
middleware.ts : https://pastebin.com/N33s1QLs
auth.config.ts : https://pastebin.com/x4NfngGi
auth.ts : https://pastebin.com/LfBcBu6S
Answered by Toyger
you can try something like that https://stackoverflow.com/a/77524597
2 Replies
Toyger
you can try something like that https://stackoverflow.com/a/77524597
Answer
Patagonian SheepdogOP
Well, I went about it in a slightly more raw way. I re-created the authentication by hand and the translations too. I was able to implement it in a rather special way, but it works (very very similar to what you sent me, thank you!)