This content originally appeared on DEV Community and was authored by Gustaf Broman
In the frontend it's as simple as...
import { signIn } from "next-auth/react";
<button
onClick={() => signIn("google", { callbackUrl: "/account" })}
>
Sign in
</Button>
And your api/auth/[...nextauth].ts
route stays the same, no extra configuration needed:
const options = {
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_OAUTH_CLIENT_ID,
clientSecret: process.env.GOOGLE_OAUTH_CLIENT_SECRET,
}),
],
adapter: PrismaAdapter(prisma),
secret: process.env.SECRET,
};
const authHandler: NextApiHandler = (req, res) => NextAuth(req, res, options);
export default authHandler;
This content originally appeared on DEV Community and was authored by Gustaf Broman
Print
Share
Comment
Cite
Upload
Translate
Updates
There are no updates yet.
Click the Upload button above to add an update.
APA
MLA
Gustaf Broman | Sciencx (2022-06-14T19:23:55+00:00) One-Click Sign In with Next Auth. Retrieved from https://www.scien.cx/2022/06/14/one-click-sign-in-with-next-auth/
" » One-Click Sign In with Next Auth." Gustaf Broman | Sciencx - Tuesday June 14, 2022, https://www.scien.cx/2022/06/14/one-click-sign-in-with-next-auth/
HARVARDGustaf Broman | Sciencx Tuesday June 14, 2022 » One-Click Sign In with Next Auth., viewed ,<https://www.scien.cx/2022/06/14/one-click-sign-in-with-next-auth/>
VANCOUVERGustaf Broman | Sciencx - » One-Click Sign In with Next Auth. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/06/14/one-click-sign-in-with-next-auth/
CHICAGO" » One-Click Sign In with Next Auth." Gustaf Broman | Sciencx - Accessed . https://www.scien.cx/2022/06/14/one-click-sign-in-with-next-auth/
IEEE" » One-Click Sign In with Next Auth." Gustaf Broman | Sciencx [Online]. Available: https://www.scien.cx/2022/06/14/one-click-sign-in-with-next-auth/. [Accessed: ]
rf:citation » One-Click Sign In with Next Auth | Gustaf Broman | Sciencx | https://www.scien.cx/2022/06/14/one-click-sign-in-with-next-auth/ |
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.