0.7.0 • Published 2 years ago

fastify-next-auth v0.7.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

fastify-next-auth

Authentication plugin for Fastify, powered by Auth.js.

Installation

npm install @auth/core fastify-next-auth

Usage

import fastify from 'fastify'
import AppleProvider from '@auth/core/providers/apple'
import GoogleProvider from '@auth/core/providers/google'
import EmailProvider from '@auth/core/providers/email'
import AuthPlugin from 'fastify-next-auth'

const app = fastify()

app
  .register(AuthPlugin, {
    secret: process.env.AUTH_SECRET,
    trustHost: process.env.AUTH_TRUST_HOST,
    providers: [
      // OAuth authentication providers
      AppleProvider({
        clientId: process.env.APPLE_ID,
        clientSecret: process.env.APPLE_SECRET,
      }),
      GoogleProvider({
        clientId: process.env.GOOGLE_ID,
        clientSecret: process.env.GOOGLE_SECRET,
      }),
      // Sign in with passwordless email link
      EmailProvider({
        server: process.env.MAIL_SERVER,
        from: '<no-reply@example.com>',
      }),
    ],
  })

Client Side Functions

import { signIn, signOut } from 'fastify-next-auth/client'

// Redirects to sign in page
signIn()

// Starts OAuth sign-in flow
signIn('google')

// Starts Email sign-in flow
signIn('email', { email: 'hello@mail.com' })

signOut()

Decorators

fastify.get('/api/user', async function (req) {
  const { user } = await this.getSession(req)
  return user
})

For more info, proceed to the Auth.js docs.

License

MIT

0.5.3

2 years ago

0.7.0

2 years ago

0.5.2

2 years ago

0.6.0

2 years ago

0.5.0

2 years ago

0.5.1

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.7

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.4

2 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.0

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago