ESC
Tutorials > User Authentication
Ready to get your peeps on board with Next Starter AI? We've got two awesome ways: Magic Links & Google Oauth. Take your pick and let's roll! 🚀
🌟 Great job finishing up one of the awesome tutorials! Now, it's high-five time! 🙌 To continue, smoothly sail over to the signin/signup page, just like this:
/SignInButton.tsx
1
2    "use client";
3
4    import Link from "next/link";
5    
6    const SigninButton = () => {
7        return (
8            <Link className="btn btn-primary" href="/signin">
9                Login
10            </Link>
11        );
12    };
13    
14    export default SigninButton;
15    In sign in/up page, the code below handles OTP and Google Login out of the box for you!
/pages/sign-in.tsx
1
2        const handleSignup = async (options: {
3            type: string;
4            provider?: Provider;
5        }) => {
6          setIsLoading(true);
7      
8          try {
9            const { type, provider } = options;
10            const redirectURL = window.location.origin + "/api/auth/callback";
11      
12            if (type === "oauth") {
13              await supabase.auth.signInWithOAuth({
14                provider,
15                options: {
16                  redirectTo: redirectURL,
17                },
18              });
19            } else if (type === "magic_link") {
20              await supabase.auth.signInWithOtp({
21                email,
22                options: {
23                  emailRedirectTo: redirectURL,
24                },
25              });
26      
27              toast.success("Check your emails!");
28      
29              setIsDisabled(true);
30            }
31          } catch (error) {
32            console.log(error);
33          } finally {
34            setIsLoading(false);
35          }
36      };
37    