User authentication
FastSaas uses NextAuth to authenticate users. You can configure it in the /app/api/auth/[...nextauth]/route.js
file.
There are 2 built-in ways to authenticate users with FastSaas: Magic Links & Google Oauth.
Once you’ve completed at least one of the tutorials above, you can login users like this:
ButtonSignin.js
"use client";
import { signIn } from "next-auth/react";
import config from "@/config";
const SigninButton = () => {
return (
<button
className="btn btn-primary"
onClick={() =>
signIn(undefined, { callbackUrl: config.auth.callbackUrl })
}
>
Login
</button>
);
};
export default SigninButton;
💡
The callbackUrl
variable in the config.js
file is used accross the app to
redirect the user at the right place after a successfull sign-up/login. It’s
usually a private page like /dashboard