WaspW
Wasp11mo ago
cooluke.

Page with optional auth - How to get user data in React if the user is signed in?

If I set authRequired: true on a page in main.wasp, then I can get the user data just fine in the React front-end like:
export const MainPage = ({ user }: { user: AuthUser }) => {


BUT, if I set authRequired: false in main.wasp, then that user object is undefined.

How do I make a page with auth "optional" (user doesn't have to be signed in to access it) but get the user data if the user does happen to be signed in?
Was this page helpful?