Skip to content

Commit 6ff1baf

Browse files
Merge pull request #301 from Nitin-kumar-yadav1307/fix-auth-ui-customization
fix: improve auth UI customization options in react sdk
2 parents f28b971 + 1a6b05f commit 6ff1baf

11 files changed

Lines changed: 1088 additions & 356 deletions

File tree

examples/react-sdk-demo/src/App.tsx

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { 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';
33
import './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

4560
function 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()}

package-lock.json

Lines changed: 0 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdks/urbackend-react/dist/index.d.mts

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,74 @@ interface GuestRouteProps {
8383
*/
8484
declare const GuestRoute: React.FC<GuestRouteProps>;
8585

86+
type AuthProvider = 'google' | 'github';
87+
type ThemeMode = 'light' | 'dark';
88+
interface AuthColors {
89+
background: string;
90+
surface: string;
91+
text: string;
92+
textMuted: string;
93+
border: string;
94+
inputBackground: string;
95+
primary: string;
96+
primaryText: string;
97+
footerBackground: string;
98+
dividerText: string;
99+
socialButtonBackground: string;
100+
}
101+
interface AuthBranding {
102+
brandName?: string;
103+
appName?: string;
104+
title?: string;
105+
subtitle?: string;
106+
logo?: React.ReactNode | string;
107+
primaryColor?: string;
108+
}
109+
interface AuthLabels {
110+
loginTab: string;
111+
signupTab: string;
112+
loginTitle: string;
113+
signupTitle: string;
114+
forgotTitle: string;
115+
resetTitle: string;
116+
loginButton: string;
117+
signupButton: string;
118+
forgotButton: string;
119+
resetButton: string;
120+
emailLabel: string;
121+
emailPlaceholder: string;
122+
passwordLabel: string;
123+
passwordPlaceholder: string;
124+
nameLabel: string;
125+
namePlaceholder: string;
126+
otpLabel: string;
127+
otpPlaceholder: string;
128+
forgotPasswordLink: string;
129+
socialDivider: string;
130+
googleButton: string;
131+
githubButton: string;
132+
footerSigninPrompt: string;
133+
footerSignupPrompt: string;
134+
footerForgotPrompt: string;
135+
noAuthMethods: string;
136+
signInTitle?: string;
137+
signUpTitle?: string;
138+
signInTab?: string;
139+
signUpTab?: string;
140+
signInButton?: string;
141+
signUpButton?: string;
142+
}
86143
interface UrAuthProps {
87-
providers?: ('google' | 'github')[];
88-
theme?: 'light' | 'dark';
144+
providers?: AuthProvider[] | {
145+
google?: boolean;
146+
github?: boolean;
147+
emailPassword?: boolean;
148+
};
149+
enableEmailPassword?: boolean;
150+
theme?: ThemeMode;
151+
colors?: Partial<AuthColors>;
152+
branding?: AuthBranding;
153+
labels?: Partial<AuthLabels>;
89154
onSuccess?: () => void;
90155
}
91156
declare const UrAuth: React.FC<UrAuthProps>;

0 commit comments

Comments
 (0)