File: index.md | Updated: 11/15/2025
🎉 NextAuth.js is now part of Better Auth !
import NextAuth from 'next-auth'import AppleProvider from 'next-auth/providers/apple'import FacebookProvider from 'next-auth/providers/facebook'import GoogleProvider from 'next-auth/providers/google'import EmailProvider from 'next-auth/providers/email'export default NextAuth({ providers: [ // OAuth authentication providers... AppleProvider({ clientId: process.env.APPLE_ID, clientSecret: process.env.APPLE_SECRET }), FacebookProvider({ clientId: process.env.FACEBOOK_ID, clientSecret: process.env.FACEBOOK_SECRET }), GoogleProvider({ clientId: process.env.GOOGLE_ID, clientSecret: process.env.GOOGLE_SECRET }), // Passwordless / email sign in EmailProvider({ server: process.env.MAIL_SERVER, from: 'NextAuth.js <no-reply@example.com>' }), ]})
import { SessionProvider } from "next-auth/react"export default function App({ Component, pageProps: { session, ...pageProps }}) { return ( <SessionProvider session={session}> <Component {...pageProps}/> </SessionProvider> )}
import { useSession, signIn, signOut } from "next-auth/react"export default function Component() { const { data: session } = useSession() if(session) { return <> Signed in as {session.user.email} <br/> <button onClick={() => signOut()}>Sign out</button> </> } return <> Not signed in <br/> <button onClick={() => signIn()}>Sign in</button> </>}
NextAuth.js is an open source community project.