Get NextJet


Authentication is the process of verifying the identity of a user. Learn how to use the pre-configured authentication hook.

User information should be considered global state, accessible from anywhere in the application.

I have pre-configured an authentication hook, apps/dashboard/src/hooks/useAuth.ts, which you can use to:

  • Check if a user is authenticated.
  • Get the user profile.
  • Verify if the user is subscribed.

The necessary logic to check user authentication before accessing the dashboard page is already implemented. If a user is not authenticated, they will be automatically redirected to the login page.

You don't need to worry about authentication logic. Simply use the useAuth hook to get user information and check if the user is subscribed to any plan.

import { useAuth } from "@/hooks/useAuth"

const { user, isSubscribed } = useAuth()

Last updated on