Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NextJS 13 - Auth Checking is not working as expected #86

Open
rgbskills opened this issue Jan 8, 2023 · 1 comment
Open

NextJS 13 - Auth Checking is not working as expected #86

rgbskills opened this issue Jan 8, 2023 · 1 comment

Comments

@rgbskills
Copy link

rgbskills commented Jan 8, 2023

I have a wrapper component that redirects unauthenticated users and renders the children (layout in my case) if the user is logged in.
But sometimes it works and sometimes it wont load anything that it is wrapped around.

"use client"

import { useAuthUser } from "@react-query-firebase/auth";
import { redirect } from 'next/navigation';
import { auth } from "../firebase-config";

export function UserRedirectOnLoggedOut({children, href}) {
  const user = useAuthUser(["user"], auth);

  if (user.isLoading) {
    return <div />;
  }

  if (user.data) {
    return (
      <>
        {children}
      </>
    );
  }

  redirect(href);
}

Can anyone help me out ?

@rgbskills rgbskills changed the title NextJS 13 Auth Checking is not working NextJS 13 - Auth Checking is not working as expected Jan 8, 2023
@kabtamu-degifie
Copy link

kabtamu-degifie commented Feb 18, 2024

The issues regarding infinite loading and disabled functionality associated with the useFirestoreDocumentData hook have been resolved. Therefore, we can now utilize it with Next.js versions 13 or 14.
#97

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants