User Authentication with Next.js and Strapi

Here is the working example with latest versions.

Thanks for the comments above. Issues were related to response structure from strapi v4.

import NextAuth from 'next-auth';
import GoogleProvider from 'next-auth/providers/google';

const options = {
	providers: [
		GoogleProvider({
			clientId: process.env.GOOGLE_CLIENT_ID,
			clientSecret: process.env.GOOGLE_CLIENT_SECRET,
		}),
	],
	session: {
		jwt: true,
	},
	callbacks: {
		async session({ session, token, user }) {
			session.jwt = token.jwt;
			session.id = token.id;
			return session;
		},
		async jwt({ token, user, account }) {
			if (user) {
				const response = await fetch(
					`${process.env.NEXT_PUBLIC_API_URL}/api/auth/google/callback?access_token=${account.access_token}`
				);
				const data = await response.json();
				token.jwt = data.jwt;
				token.id = data.user.id;
			}
			return token;
		},
	},
};

const Auth = (req, res) => NextAuth(req, res, options);

export default Auth;

EDIT: Database URL not needed on frontend.