Authentication
Authenticate users using our system.
Table of Contents
- Overview
- Key Features
- Use Cases
- Getting Started
- API Overview
- Templates
- Comparison to Alternatives
- FAQ
Overview
The Authentication Plugin is a ready-to-use solution for adding user authentication to your FastStartup project.
It includes everything you need to handle login, magic links, and provider logins (like Google).
You just need to set up the environment variables and the database plugin, and it works right out of the box.
Key Features
- Passwordless login with magic links.
- Provider login support (Google).
- Smooth user experience.
- Built using AuthJS for security and flexibility.
Use Cases
- Allow users to sign in without passwords (magic links).
- Let users log in using Google credentials.
- Ensure a fast and safe authentication system.
- Quick setup for authentication in your SaaS app.
Getting Started
-
Install the Database Plugin Make sure you have the Database Plugin installed.
-
Set Up Environment Variables Add the following variables to your
.env
file:AUTH_SECRET="your_auth_secret" AUTH_GOOGLE_ID="your_google_id" # Optional AUTH_GOOGLE_SECRET="your_google_secret" # Optional AUTH_RESEND_KEY="your_resend_key" NEXT_PUBLIC_RESEND_EMAIL="your_public_email"
AUTH_GOOGLE_ID
andAUTH_GOOGLE_SECRET
are only needed if Google login is enabled.
-
Ready-Made Templates are used
You can import the templates in your project (Already used in
/auth/login
, no extra work needed):import { LoginTemplate, AuthenticationLayoutTemplate, } from "@/templates/authentication";
-
Routes Are Preconfigured The route handlers are already set up in
/api/auth/
. No extra work is needed. -
Start Using Authentication The plugin is ready. Add the environment variables, and you're good to go.
API Overview
Method | Description |
---|---|
auth | Returns the AuthJS session data. |
getUser | Fetch the authenticated user details. |
routeHandlers | Built-in handlers for authentication routes. |
signInWithGoogle | Trigger Google login. |
signInWithMagicLink | Send a magic link to the user's email. |
signOut | Log the user out. |
Unauthenticated | A component to display content only to unauthenticated users. |
Authenticated | A component to display content only to authenticated users. |
Templates
You can use these templates in your project:
LoginTemplate
: Ready-made login page for your users.AuthenticationLayoutTemplate
: A layout that wraps authentication components.
Import them like this:
import {
LoginTemplate,
AuthenticationLayoutTemplate,
} from "@/templates/authentication";
Comparison to Alternatives
Other authentication tools can be complicated to set up.
The Authentication Plugin for FastStartup is preconfigured.
It requires minimal setup. No need to worry about routes, database integration, or UI templates.
Just set the environment variables and start using it.
FAQ
Do I need the Database Plugin?
Yes, the Authentication Plugin depends on the Database Plugin. Make sure it's installed.
Is Google login required?
No, Google login is optional. It's only needed if you enable provider login.
Where do I configure the environment variables?
Add the required variables to your .env
file.
What do I need for magic link login?
You need the AUTH_RESEND_KEY
and NEXT_PUBLIC_RESEND_EMAIL
environment variables set.
Is the UI included?
Yes, ready-to-use templates (LoginTemplate
and AuthenticationLayoutTemplate
) are included.
With the Authentication Plugin, you can get secure and passwordless authentication running in no time.
It's designed to save you time and give your users a smooth experience.
Set it up, and you're ready to go!
Build, Launch, and Grow Your SaaS
Get everything you need to launch your SaaS and land your first paying user—starting today.