Skip to Content
ForgeStack 1.3.8 is released 🎉
UsageAuthentication

Authentication in ForgeStack

ForgeStack provides built-in support for Firebase Authentication, allowing you to easily manage user sign-in, sign-up, and authentication state.

Setting Up Firebase Authentication

To get started with authentication in your ForgeStack application, ensure you have set up Firebase Authentication in your Firebase project:

  1. Go to the Firebase Console .
  2. Select your project.
  3. Navigate to the “Authentication” section and click on “Get Started”.
  4. Enable the desired sign-in methods (e.g., Email/Password, Google, etc.).

Using the useAuth Hook

ForgeStack includes a custom authentication hook, useAuth.ts, which simplifies user authentication.

Example Usage:

import { handleGoogleAuth, handleLogout } from "@/hooks/useAuth"; import { useUser } from "@/context/usercontext"; export default function AuthExample(){ const { user } = useUser(); return ( <div> {user ? ( <button onClick={handleLogout}>Logout</button> ) : ( <button onClick={handleGoogleAuth}>Sign in with Google</button> )} </div> ); }

Features of useAuth.ts

  • Google Authentication – Sign in with Google using Firebase.
  • User Authentication Handling – Supports email/password sign-in and sign-up.
  • Sign-Out Support – Allows users to log out easily.

Next Steps

Now your app is ready to authenticate users seamlessly! 🚀