11import { useState , useEffect } from 'react' ;
2- import { UrAuth , ProtectedRoute , GuestRoute , useUser , UrUserButton } from '@urbackend/react' ;
2+ import { UrAuth , ProtectedRoute , GuestRoute , useUser , useAuth , UrUserButton } from '@urbackend/react' ;
33import './App.css' ;
44
55// Mini router component for the demo
@@ -28,7 +28,22 @@ function App() {
2828 return (
2929 < GuestRoute fallback = { LoadingFallback } onRedirect = { ( ) => navigate ( '/' ) } >
3030 < div style = { { display : 'flex' , justifyContent : 'center' , alignItems : 'center' , minHeight : '100vh' , background : '#f8fafc' } } >
31- < UrAuth providers = { [ 'google' , 'github' ] } theme = "light" />
31+ < UrAuth
32+ providers = { {
33+ github : true ,
34+ google : true ,
35+ emailPassword : true ,
36+ } }
37+ branding = { {
38+ appName : "My Custom App" ,
39+ logo : "https://vite.dev/logo.svg" ,
40+ primaryColor : "#4F46E5" ,
41+ } }
42+ labels = { {
43+ signInTitle : "Welcome back to Custom App" ,
44+ signInButton : "Proceed to App" ,
45+ } }
46+ />
3247 </ div >
3348 </ GuestRoute >
3449 ) ;
@@ -43,7 +58,8 @@ function App() {
4358}
4459
4560function Dashboard ( ) {
46- const { user, logout } = useUser ( ) ;
61+ const { user } = useUser ( ) ;
62+ const { logout } = useAuth ( ) ;
4763
4864 return (
4965 < div style = { { display : 'flex' , justifyContent : 'center' , alignItems : 'center' , minHeight : '100vh' , background : '#f8fafc' , padding : '24px' } } >
@@ -66,8 +82,8 @@ function Dashboard() {
6682 } } >
6783
6884 < div style = { { display : 'flex' , alignItems : 'center' , gap : '16px' , marginBottom : '32px' } } >
69- { user ?. avatarUrl ? (
70- < img src = { user . avatarUrl } alt = "Avatar" style = { { width : '64px' , height : '64px' , borderRadius : '0' , objectFit : 'cover' } } />
85+ { typeof user ?. avatarUrl === 'string' && user ?. avatarUrl ? (
86+ < img src = { user . avatarUrl } alt = "Avatar" style = { { width : '64px' , height : '64px' , borderRadius : '0' , objectFit : 'cover' } } />
7187 ) : (
7288 < div style = { { width : '64px' , height : '64px' , borderRadius : '0' , background : 'linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%)' , display : 'flex' , alignItems : 'center' , justifyContent : 'center' , fontSize : '24px' , fontWeight : 600 , color : '#64748b' } } >
7389 { user ?. name ?. [ 0 ] ?. toUpperCase ( ) || user ?. email ?. [ 0 ] ?. toUpperCase ( ) }
0 commit comments