I'm setting up nextauth in a nextjs 13 app using credentials and email (login link) and jwt for session storage. I'm struggling to wrap my mind around the best practices for (1) creating an access token and (2) creating a new token (or refresh token) when it expires.
Currently, I'm creating the token in the login route, but that won't help with the email provider. I'm not sure if I should be creating the token in the jwt or session callback instead? Likewise, I'm not sure the best practice for checking token expiration and getting that back to the client.
Has anyone ever found a good example of this?
I'm can share code if that would help, and any assistance would be greatly appreciated.