user17999103
user17999103

Reputation:

signUp from 'next-auth/react' doesn't exist

I'm trying to create a sign up page and currently integrate signup with google with nextauth.

I have been able to integrate signIn with nextAuth and able to sign in (However not able to create an actual user on the database...)

with:

import { getProviders, signIn as SignIntoProvider } from 'next-auth/react';

where signIn exists in next-auth/react-- when searching for signUp or newUser, it doesn't exist... is there any other place where I should be looking for?

As there is supposed to be signIn, signUp, and signOut. I'm not able to access signUp for some reason...

Upvotes: 2

Views: 3482

Answers (2)

Vineet Verma
Vineet Verma

Reputation: 71

But you can create your own route in the API. something like /api/auth/signup.js and then handle the signup process inside that.

async function handler(req, res) {
  if (req.method !== "POST") {
    return;
  }

  const data = req.body;

  const { email, password } = data;

  if (
    !email ||
    !email.includes("@") ||
    !password ||
    password.trim().length < 7
  ) {
    res.status(422).json({
      message:
        "Invalid input - password should also be at least 7 characters long.",
    });
    return;
  }

... YOUR SIGNUP LOGIC ...

}

export default handler;

Upvotes: 0

Gustavo Galupo
Gustavo Galupo

Reputation: 136

The signUp function doesn't exists, but you can use NextAuth callbacks to save the user on your database.

When a user sign in, query the db to check if it already exists, and if it doesn't, you create it.

Here is the documentation reference of how to use the signIn callback:

NextAuth Callbacks documentation

Upvotes: 2

Related Questions