Authentication
Saves up to 40 hours

Authentication

Authenticate users using our system.

Installed by Default

Table of Contents

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

  1. Install the Database Plugin Make sure you have the Database Plugin installed.

  2. 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 and AUTH_GOOGLE_SECRET are only needed if Google login is enabled.
  3. 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";
    
  4. Routes Are Preconfigured The route handlers are already set up in /api/auth/. No extra work is needed.

  5. Start Using Authentication The plugin is ready. Add the environment variables, and you're good to go.

API Overview

MethodDescription
authReturns the AuthJS session data.
getUserFetch the authenticated user details.
routeHandlersBuilt-in handlers for authentication routes.
signInWithGoogleTrigger Google login.
signInWithMagicLinkSend a magic link to the user's email.
signOutLog the user out.
UnauthenticatedA component to display content only to unauthenticated users.
AuthenticatedA 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!



Save 1,000+ Hours

By signing up, you agree with our Privacy Policy.

Build, Launch, and Grow Your SaaS

Get everything you need to launch your SaaS and land your first paying user—starting today.