wobsoriano / fastify-next-auth

Auth.js plugin for Fastify.
MIT License
49 stars 3 forks source link

Client usage with SPA #7

Open teddybee opened 1 year ago

teddybee commented 1 year ago

I would like to use this with React SPA. How can it be possible? (or is it restricted only for SSR?)

wobsoriano commented 1 year ago

There is an available doc for client-side usage in the README:

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()
teddybee commented 1 year ago

I saw it, but how can the lib knows the backend`s address? My frontend is on localhost:3000, the backend is on localhost:5000.

wobsoriano commented 1 year ago

Related https://github.com/nextauthjs/next-auth/discussions/1299