3 ms·
Can you explain the example in the docs? Here’s an example. To retrieve the current user, simply call: export function MyComponent() { const
by 8organicbits 2y ago
Can you explain the example in the docs?
Here’s an example. To retrieve the current user, simply call:
export function MyComponent() {
const user = useUser({ or: "redirect" });
return <div>{user ? `Hi, ${user.displayName}` : 'You are not logged in'}</div>;
}
That’s it! Stack will either return a User object or redirect the user to the login page.
It seems like the "not logged in" message is dead code as the earlier logic would instead redirect to the login page. Am I misunderstanding something?
- n2d4 2y agoYou're right. Thanks, fixed!