invertase / invertase/tanstack-query-firebase

NextJS 13 - Auth Checking is not working as expected

Open
#86 1 comment 0 reactions 0 assignees View on GitHub
react-query-firebase
Dominant language
TypeScript
Stars
462
Forks
69
PR merge metrics
No merged PRs in 30d

Description

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.

```js
"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

;
}

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

);
}

redirect(href);
}
```

Can anyone help me out ?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.