How to use the next-auth/client.NextAuth.providers function in next-auth

To help you get started, we’ve selected a few next-auth examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github iaincollins / nextjs-starter / pages / auth / index.js View on Github external
static async getInitialProps({req, res, query}) {
    let props = await super.getInitialProps({req})
    props.session = await NextAuth.init({force: true, req: req})
    props.providers = await NextAuth.providers({req})
    
    // If signed in already, redirect to account management page.
    if (props.session.user) {
      if (req) {
        res.redirect('/account')
      } else {
        Router.push('/account')
      }
    }

    // If passed a redirect parameter, save it as a cookie
    if (query.redirect) {
      const cookies = new Cookies((req && req.headers.cookie) ? req.headers.cookie : null)
      cookies.set('redirect_url', query.redirect, { path: '/' })
    }
github datavis-tech / vizhub-legacy / packages / web / pages / auth / index.js View on Github external
static async getInitialProps({req, res, query}) {
    const props = await super.getInitialProps({req});
    const session = await NextAuth.init({force: true, req: req});
    props.user = userFromSession(session);
    props.providers = await NextAuth.providers({req});
    
    // If signed in already, redirect to account management page.
    if (props.user.authenticated) {
      if (req) {
        res.redirect('/account');
      } else {
        Router.push('/account');
      }
    }

    // If passed a redirect parameter, save it as a cookie
    if (query.redirect) {
      const cookies = new Cookies((req && req.headers.cookie) ? req.headers.cookie : null);
      cookies.set('redirect_url', query.redirect, { path: '/' });
    }
github iaincollins / nextjs-starter / components / layout.js View on Github external
async toggleModal(e) {
    if (e) e.preventDefault()

    // Save current URL so user is redirected back here after signing in
    if (this.state.modal !== true) {
      const cookies = new Cookies()
      cookies.set('redirect_url', window.location.pathname, { path: '/' })
    }

    this.setState({
      providers: this.state.providers || await NextAuth.providers(),
      modal: !this.state.modal
    })
  }
github iaincollins / next-auth / example / pages / auth / index.js View on Github external
static async getInitialProps({req}) {
    return {
      session: await NextAuth.init({req}),
      linkedAccounts: await NextAuth.linked({req}),
      providers: await NextAuth.providers({req})
    }
  }
github iaincollins / next-auth / example / pages / auth / credentials.js View on Github external
static async getInitialProps({req}) {
    return {
      session: await NextAuth.init({req}),
      linkedAccounts: await NextAuth.linked({req}),
      providers: await NextAuth.providers({req})
    }
  }