• Blog
  • Documentation
  • Courses
  • Changelog
  • AI Starters
  • UI Kit
  • FAQ
  • Supamode
    New
  • Pricing

Launch your next SaaS in record time with Makerkit, a React SaaS Boilerplate for Next.js and Supabase.

Makerkit is a product of Makerkit Pte Ltd (registered in the Republic of Singapore)Company Registration No: 202407149CFor support or inquiries, please contact us

About
  • FAQ
  • Contact
  • Verify your Discord
  • Consultation
  • Open Source
  • Become an Affiliate
Product
  • Documentation
  • Blog
  • Changelog
  • UI Blocks
  • Figma UI Kit
  • AI SaaS Starters
License
  • Activate License
  • Upgrade License
  • Invite Member
Legal
  • Terms of License
    • Auth Overview
    • Setting up Firebase Auth
    • Auth Flow
    • Third-Party Providers
    • Email Link Authentication
    • Multi-Factor Authentication
    • Requiring Email verification
    • Auth SSR
    • Page Guards
    • API Guards
    • Prevent abuse with AppCheck
    • Custom React Hooks
    • Troubleshooting

Authentication React Hooks

Reference for the authentication React hooks

Makerkit provides a set of React hooks to help you manage authentication in your React application. These hooks are an addition to the ones provided by reactfire.

useUserSession

This hook returns the current user session. It contains the user's auth data from Firebase, and its data record from Firestore. Basically, it wraps the UserSessionContext value.

tsx
import { useUserSession } from "~/core/hooks/use-user-session";
const userSession = useUserSession();

useUserId

This hook returns the current user's ID.

tsx
import { useUserId } from "~/core/hooks/use-user-id";
const userId = useUserId();

useCreateServerSideSession

This hook returns a function that can be used to create a server-side session. It is useful for creating a session when a user logs in, or when a user is created.

You shouldn't be needing this unless you're customizing the authentication flow.

tsx
import { useCreateServerSideSession } from "~/core/hooks/use-create-server-side-session";
const [sessionRequest, { loading, error }] = useCreateServerSideSession();
On this page
  1. useUserSession
    1. useUserId
      1. useCreateServerSideSession