“Instal Auth Berikutnya” Kode Jawaban

Instal Auth Berikutnya

npm i --save next-auth
Happy Hummingbird

Instal Next-Auth

import { useSession, signIn, signOut } from "next-auth/client"

export default function Component() {
  const [session, loading] = 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>
    </>
  )
}
Cheerful Chimpanzee

Instal Next-Auth

import NextAuth from "next-auth"
import Providers from "next-auth/providers"

export default NextAuth({
  providers: [
    // OAuth authentication providers
    Providers.Apple({
      clientId: process.env.APPLE_ID,
      clientSecret: process.env.APPLE_SECRET,
    }),
    Providers.Google({
      clientId: process.env.GOOGLE_ID,
      clientSecret: process.env.GOOGLE_SECRET,
    }),
    // Sign in with passwordless email link
    Providers.Email({
      server: process.env.MAIL_SERVER,
      from: "<[email protected]>",
    }),
  ],
  // SQL or MongoDB database (or leave empty)
  database: process.env.DATABASE_URL,
})
Cheerful Chimpanzee

Jawaban yang mirip dengan “Instal Auth Berikutnya”

Pertanyaan yang mirip dengan “Instal Auth Berikutnya”

Lebih banyak jawaban terkait untuk “Instal Auth Berikutnya” di Shell/Bash

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya