@insforge/react 0.3.5 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +476 -604
  2. package/dist/atoms.cjs +837 -0
  3. package/dist/atoms.cjs.map +1 -0
  4. package/dist/atoms.d.cts +253 -0
  5. package/dist/atoms.d.ts +111 -245
  6. package/dist/atoms.js +412 -468
  7. package/dist/atoms.js.map +1 -1
  8. package/dist/components.cjs +2000 -0
  9. package/dist/components.cjs.map +1 -0
  10. package/dist/components.d.cts +258 -0
  11. package/dist/components.d.ts +71 -123
  12. package/dist/components.js +1040 -1428
  13. package/dist/components.js.map +1 -1
  14. package/dist/forms.cjs +1194 -0
  15. package/dist/forms.cjs.map +1 -0
  16. package/dist/forms.d.cts +135 -0
  17. package/dist/forms.d.ts +113 -163
  18. package/dist/forms.js +657 -943
  19. package/dist/forms.js.map +1 -1
  20. package/dist/{hooks.mjs → hooks.cjs} +15 -13
  21. package/dist/hooks.cjs.map +1 -0
  22. package/dist/{hooks.d.mts → hooks.d.cts} +1 -1
  23. package/dist/hooks.js +9 -15
  24. package/dist/hooks.js.map +1 -1
  25. package/dist/index.cjs +2461 -0
  26. package/dist/index.cjs.map +1 -0
  27. package/dist/{index.d.mts → index.d.cts} +37 -22
  28. package/dist/index.d.ts +34 -19
  29. package/dist/index.js +1142 -1497
  30. package/dist/index.js.map +1 -1
  31. package/dist/{lib.mjs → lib.cjs} +13 -11
  32. package/dist/lib.cjs.map +1 -0
  33. package/dist/{lib.d.mts → lib.d.cts} +1 -8
  34. package/dist/lib.d.ts +1 -8
  35. package/dist/lib.js +4 -17
  36. package/dist/lib.js.map +1 -1
  37. package/dist/{router.mjs → router.cjs} +14 -16
  38. package/dist/router.cjs.map +1 -0
  39. package/dist/{router.d.mts → router.d.cts} +0 -11
  40. package/dist/router.d.ts +0 -11
  41. package/dist/router.js +10 -16
  42. package/dist/router.js.map +1 -1
  43. package/dist/styles.css +864 -2
  44. package/dist/types.cjs +4 -0
  45. package/dist/{types.mjs.map → types.cjs.map} +1 -1
  46. package/dist/types.d.cts +32 -0
  47. package/dist/types.d.ts +11 -613
  48. package/dist/types.js +0 -1
  49. package/package.json +111 -98
  50. package/dist/atoms.d.mts +0 -387
  51. package/dist/atoms.mjs +0 -861
  52. package/dist/atoms.mjs.map +0 -1
  53. package/dist/components.d.mts +0 -310
  54. package/dist/components.mjs +0 -2327
  55. package/dist/components.mjs.map +0 -1
  56. package/dist/forms.d.mts +0 -185
  57. package/dist/forms.mjs +0 -1468
  58. package/dist/forms.mjs.map +0 -1
  59. package/dist/hooks.mjs.map +0 -1
  60. package/dist/index.mjs +0 -2724
  61. package/dist/index.mjs.map +0 -1
  62. package/dist/lib.mjs.map +0 -1
  63. package/dist/router.mjs.map +0 -1
  64. package/dist/types.d.mts +0 -634
  65. package/dist/types.mjs +0 -3
  66. package/src/styles.css +0 -15
package/README.md CHANGED
@@ -1,604 +1,476 @@
1
- # @insforge/react
2
-
3
- **Complete authentication solution for React applications.** Production-ready components with full business logic included.
4
-
5
- ## Why @insforge/react?
6
-
7
- ✅ **5-Minute Setup** - One provider + one line of router config = done
8
- ✅ **Built-in Auth UI** - Use deployed auth pages (like Next.js middleware)
9
- ✅ **Framework Agnostic** - Works with any React framework
10
- ✅ **Full TypeScript** - Complete type safety out of the box
11
- ✅ **Fully Customizable** - Deep styling control when you need it
12
-
13
- ---
14
-
15
- ## Quick Start
16
-
17
- Get authentication working in your React app in 5 minutes.
18
-
19
- ### 1. Install
20
-
21
- ```bash
22
- npm install @insforge/react
23
- # or
24
- yarn add @insforge/react
25
- # or
26
- pnpm add @insforge/react
27
- ```
28
-
29
- ### 2. Setup Provider
30
-
31
- Wrap your app with `InsforgeProvider`:
32
-
33
- ```tsx
34
- // src/main.tsx (Vite) or src/index.tsx (CRA)
35
- import { StrictMode } from 'react';
36
- import { createRoot } from 'react-dom/client';
37
- import { InsforgeProvider } from '@insforge/react';
38
- import '@insforge/react/styles.css';
39
- import App from './App';
40
-
41
- createRoot(document.getElementById('root')!).render(
42
- <StrictMode>
43
- <InsforgeProvider baseUrl={import.meta.env.VITE_INSFORGE_BASE_URL}>
44
- <App />
45
- </InsforgeProvider>
46
- </StrictMode>
47
- );
48
- ```
49
-
50
- ### 3. Configure Router (Built-in Auth)
51
-
52
- ```tsx
53
- // src/App.tsx
54
- import { createBrowserRouter, RouterProvider } from 'react-router-dom';
55
- import { getInsforgeRoutes } from '@insforge/react/router';
56
- import Home from './pages/Home';
57
- import Dashboard from './pages/Dashboard';
58
-
59
- const router = createBrowserRouter([
60
- { path: '/', element: <Home /> },
61
-
62
- ...getInsforgeRoutes({
63
- baseUrl: import.meta.env.VITE_INSFORGE_BASE_URL,
64
- builtInAuth: true
65
- }),
66
-
67
- { path: '/dashboard', element: <Dashboard /> }
68
- ]);
69
-
70
- export default function App() {
71
- return <RouterProvider router={router} />;
72
- }
73
- ```
74
-
75
- **What this does:**
76
- - Visiting `/sign-in` → Redirects to `your-project.insforge.app/auth/sign-in`
77
- - Visiting `/sign-up`Redirects to `your-project.insforge.app/auth/sign-up`
78
- - After auth → Redirects back to `/auth/callback` → Goes to dashboard
79
-
80
- ### 4. Add Auth UI to Your Pages
81
-
82
- ```tsx
83
- // src/pages/Home.tsx
84
- import { SignedIn, SignedOut, UserButton } from '@insforge/react';
85
-
86
- export default function Home() {
87
- return (
88
- <div>
89
- <nav>
90
- <SignedOut>
91
- <a href="/sign-in">Sign In</a>
92
- </SignedOut>
93
-
94
- <SignedIn>
95
- <UserButton afterSignOutUrl="/" />
96
- </SignedIn>
97
- </nav>
98
-
99
- <h1>Welcome to My App!</h1>
100
- </div>
101
- );
102
- }
103
- ```
104
-
105
- **That's it!** 🎉 You now have production-ready authentication.
106
-
107
- ---
108
-
109
- ## Router Configuration Options
110
-
111
- ### Built-in Auth (Recommended)
112
-
113
- Uses your deployed Insforge auth pages (includes all flows):
114
-
115
- ```tsx
116
- ...getInsforgeRoutes({
117
- baseUrl: 'https://your-project.insforge.app',
118
- builtInAuth: true, // Default
119
- paths: {
120
- signIn: '/sign-in', // Sign in page
121
- signUp: '/sign-up', // Sign up page
122
- verifyEmail: '/verify-email', // Email verification page
123
- forgotPassword: '/forgot-password', // Request password reset
124
- resetPassword: '/reset-password', // Reset password with token
125
- callback: '/auth/callback' // OAuth callback handler
126
- }
127
- })
128
- ```
129
-
130
- ### Custom UI Components
131
-
132
- Use package components with your own styling:
133
-
134
- ```tsx
135
- import {
136
- SignIn,
137
- SignUp,
138
- ForgotPassword,
139
- ResetPassword,
140
- VerifyEmail
141
- } from '@insforge/react';
142
-
143
- const router = createBrowserRouter([
144
- { path: '/', element: <Home /> },
145
-
146
- // Still need callback route for OAuth
147
- ...getInsforgeRoutes({
148
- baseUrl: import.meta.env.VITE_INSFORGE_BASE_URL,
149
- builtInAuth: false // Don't redirect to deployed UI
150
- }),
151
-
152
- // Use package components for complete auth flows
153
- { path: '/sign-in', element: <SignIn afterSignInUrl="/dashboard" /> },
154
- { path: '/sign-up', element: <SignUp afterSignUpUrl="/dashboard" /> },
155
- { path: '/forgot-password', element: <ForgotPassword backToSignInUrl="/sign-in" /> },
156
- { path: '/reset-password', element: <ResetPassword token={searchParams.get('token')} /> },
157
- { path: '/verify-email', element: <VerifyEmail token={searchParams.get('token')} /> }
158
- ]);
159
- ```
160
-
161
- ### Fully Custom UI
162
-
163
- Build your own auth pages from scratch:
164
-
165
- ```tsx
166
- import { useAuth } from '@insforge/react';
167
-
168
- function CustomSignIn() {
169
- const { signIn } = useAuth();
170
-
171
- const handleSubmit = async (e) => {
172
- e.preventDefault();
173
- await signIn(email, password);
174
- navigate('/dashboard');
175
- };
176
-
177
- return <form onSubmit={handleSubmit}>...</form>;
178
- }
179
- ```
180
-
181
- ---
182
-
183
- ## Core Features
184
-
185
- ### Components
186
-
187
- **Pre-built with Business Logic:**
188
- - `<SignIn />` - Complete sign-in with email/password & OAuth
189
- - `<SignUp />` - Registration with password validation & email verification
190
- - `<ForgotPassword />` - Request password reset with email validation
191
- - `<ResetPassword />` - Reset password with token validation
192
- - `<VerifyEmail />` - Verify email with automatic token handling
193
- - `<UserButton />` - User dropdown with sign-out
194
- - `<Protect />` - Route protection wrapper
195
- - `<SignedIn>` / `<SignedOut>` - Conditional rendering
196
- - `<InsforgeCallback />` - OAuth callback handler
197
-
198
- **Form Components (Pure UI):**
199
- - `<SignInForm />` - Sign-in UI without logic
200
- - `<SignUpForm />` - Sign-up UI without logic
201
- - `<ForgotPasswordForm />` - Password reset request UI
202
- - `<ResetPasswordForm />` - Password reset with token UI
203
- - `<VerifyEmailStatus />` - Email verification status UI
204
-
205
- **Atomic Components (14 total):**
206
- - `<AuthContainer />`, `<AuthHeader />`, `<AuthFormField />`, `<AuthPasswordField />`, `<AuthEmailVerificationStep />`, etc.
207
-
208
- ### Hooks
209
-
210
- ```tsx
211
- const { signIn, signUp, signOut, isSignedIn, isLoaded } = useAuth();
212
- const { user, updateUser, isLoaded } = useUser();
213
- const { oauthProviders, authConfig, isLoaded } = usePublicAuthConfig();
214
- ```
215
-
216
- ---
217
-
218
- ## Customization
219
-
220
- ### Basic Styling
221
-
222
- All components support `appearance` props:
223
-
224
- ```tsx
225
- <SignIn
226
- appearance={{
227
- container: "max-w-lg",
228
- card: "bg-white shadow-2xl",
229
- button: "bg-blue-600 hover:bg-blue-700"
230
- }}
231
- />
232
-
233
- // Works with all auth components
234
- <ForgotPassword
235
- appearance={{
236
- card: "bg-gradient-to-br from-indigo-50 to-white",
237
- button: "bg-indigo-600 hover:bg-indigo-700"
238
- }}
239
- />
240
- ```
241
-
242
- ### Deep Customization (Hierarchical Appearance)
243
-
244
- Style nested components through hierarchical structure:
245
-
246
- ```tsx
247
- <SignIn
248
- appearance={{
249
- card: "bg-gradient-to-br from-blue-50 to-white shadow-2xl",
250
- header: {
251
- title: "text-3xl font-bold text-purple-900",
252
- subtitle: "text-purple-600"
253
- },
254
- form: {
255
- emailField: {
256
- label: "text-gray-800 font-semibold",
257
- input: "border-purple-300 focus:border-purple-500 rounded-lg"
258
- },
259
- passwordField: {
260
- input: "border-purple-300 focus:border-purple-500 rounded-lg",
261
- forgotPasswordLink: "text-purple-600 hover:text-purple-800"
262
- }
263
- },
264
- button: "bg-purple-600 hover:bg-purple-700 rounded-lg h-12",
265
- link: {
266
- text: "text-gray-600",
267
- link: "text-purple-600 hover:text-purple-800 font-semibold"
268
- },
269
- oauth: {
270
- button: "border-2 hover:bg-gray-50 rounded-xl"
271
- }
272
- }}
273
- />
274
- ```
275
-
276
- #### Complete Appearance Structure
277
-
278
- **All auth components** (`SignIn`, `SignUp`, `ForgotPassword`, `ResetPassword`) support hierarchical appearance:
279
-
280
- ```typescript
281
- appearance?: {
282
- container?: string; // Outermost wrapper
283
- card?: string; // Inner card box
284
- header?: {
285
- container?: string; // Header wrapper
286
- title?: string; // Title text
287
- subtitle?: string; // Subtitle text
288
- };
289
- errorBanner?: string; // Error message banner
290
- form?: {
291
- container?: string; // Form wrapper
292
- emailField?: { // Available in SignIn, SignUp, ForgotPassword
293
- container?: string;
294
- label?: string;
295
- input?: string;
296
- };
297
- passwordField?: { // Available in SignIn, SignUp, ResetPassword
298
- container?: string;
299
- label?: string;
300
- input?: string;
301
- forgotPasswordLink?: string; // SignIn only
302
- strengthIndicator?: { // SignUp and ResetPassword
303
- container?: string;
304
- requirement?: string;
305
- };
306
- };
307
- };
308
- button?: string; // Submit button
309
- link?: {
310
- container?: string; // Link section wrapper
311
- text?: string; // Link description text
312
- link?: string; // Actual link element
313
- };
314
- divider?: string; // "or" divider (SignIn, SignUp)
315
- oauth?: { // OAuth section (SignIn, SignUp)
316
- container?: string;
317
- button?: string;
318
- };
319
- }
320
- ```
321
-
322
- ### Text Customization
323
-
324
- All components support full text customization:
325
-
326
- ```tsx
327
- <SignIn
328
- title="Welcome Back!"
329
- subtitle="We're happy to see you again"
330
- emailLabel="Your Email Address"
331
- emailPlaceholder="you@company.com"
332
- passwordLabel="Your Password"
333
- submitButtonText="Login Now"
334
- loadingButtonText="Signing you in..."
335
- signUpText="New to our platform?"
336
- signUpLinkText="Create an account"
337
- dividerText="or continue with"
338
- />
339
-
340
- <ForgotPassword
341
- title="Reset Your Password"
342
- subtitle="Enter your email to receive a reset code"
343
- emailLabel="Email Address"
344
- submitButtonText="Send Reset Code"
345
- backToSignInText="Remember your password?"
346
- successTitle="Check Your Email"
347
- successMessage="We've sent a reset code to your inbox"
348
- />
349
- ```
350
-
351
- ---
352
-
353
- ## Advanced Usage
354
-
355
- ### Complete Component with Custom Logic
356
-
357
- ```tsx
358
- import { SignInForm, useAuth } from '@insforge/react';
359
- import { useState } from 'react';
360
-
361
- function CustomSignIn() {
362
- const { signIn } = useAuth();
363
- const [email, setEmail] = useState('');
364
- const [password, setPassword] = useState('');
365
- const [error, setError] = useState('');
366
- const [loading, setLoading] = useState(false);
367
-
368
- const handleSubmit = async (e: React.FormEvent) => {
369
- e.preventDefault();
370
- setLoading(true);
371
- setError('');
372
-
373
- try {
374
- await signIn(email, password);
375
- // Custom success logic
376
- } catch (err) {
377
- setError(err.message);
378
- } finally {
379
- setLoading(false);
380
- }
381
- };
382
-
383
- return (
384
- <SignInForm
385
- email={email}
386
- password={password}
387
- onEmailChange={setEmail}
388
- onPasswordChange={setPassword}
389
- onSubmit={handleSubmit}
390
- error={error}
391
- loading={loading}
392
- availableProviders={['google', 'github']}
393
- onOAuthClick={(provider) => {
394
- // Custom OAuth logic
395
- }}
396
- />
397
- );
398
- }
399
- ```
400
-
401
- ### Build from Atomic Components
402
-
403
- ```tsx
404
- import {
405
- AuthContainer,
406
- AuthHeader,
407
- AuthFormField,
408
- AuthPasswordField,
409
- AuthSubmitButton,
410
- AuthErrorBanner,
411
- AuthDivider,
412
- AuthOAuthProviders,
413
- AuthLink,
414
- } from '@insforge/react';
415
-
416
- function CompletelyCustomAuth() {
417
- return (
418
- <AuthContainer
419
- appearance={{
420
- containerClassName: "max-w-md",
421
- cardClassName: "bg-white shadow-2xl"
422
- }}
423
- >
424
- <AuthHeader
425
- title="Welcome to MyApp"
426
- subtitle="Sign in to continue"
427
- appearance={{
428
- titleClassName: "text-3xl text-blue-900"
429
- }}
430
- />
431
-
432
- <AuthErrorBanner error={error} />
433
-
434
- <form onSubmit={handleSubmit}>
435
- <AuthFormField
436
- id="email"
437
- type="email"
438
- label="Email"
439
- value={email}
440
- onChange={(e) => setEmail(e.target.value)}
441
- appearance={{
442
- inputClassName: "border-blue-500"
443
- }}
444
- />
445
-
446
- <AuthPasswordField
447
- id="password"
448
- label="Password"
449
- value={password}
450
- onChange={(e) => setPassword(e.target.value)}
451
- authConfig={config}
452
- showStrengthIndicator
453
- />
454
-
455
- <AuthSubmitButton isLoading={loading}>
456
- Sign In
457
- </AuthSubmitButton>
458
- </form>
459
-
460
- <AuthDivider text="or" />
461
-
462
- <AuthOAuthProviders
463
- providers={['google', 'github', 'discord']}
464
- onClick={handleOAuth}
465
- loading={oauthLoading}
466
- />
467
-
468
- <AuthLink
469
- text="Don't have an account?"
470
- linkText="Sign up"
471
- href="/sign-up"
472
- />
473
- </AuthContainer>
474
- );
475
- }
476
- ```
477
-
478
- ### Route Protection
479
-
480
- ```tsx
481
- import { Protect } from '@insforge/react';
482
-
483
- function Dashboard() {
484
- return (
485
- <div>
486
- <h1>Dashboard</h1>
487
-
488
- {/* Simple protection */}
489
- <Protect redirectTo="/sign-in">
490
- <UserContent />
491
- </Protect>
492
-
493
- {/* Role-based protection */}
494
- <Protect
495
- redirectTo="/unauthorized"
496
- condition={(user) => user.role === 'admin'}
497
- >
498
- <AdminPanel />
499
- </Protect>
500
- </div>
501
- );
502
- }
503
- ```
504
-
505
- ---
506
-
507
- ## TypeScript
508
-
509
- Full TypeScript support with exported types:
510
-
511
- ```tsx
512
- import type {
513
- InsforgeUser,
514
- SignInProps,
515
- SignUpProps,
516
- ForgotPasswordProps,
517
- ResetPasswordProps,
518
- VerifyEmailProps,
519
- SignInAppearance,
520
- SignUpAppearance,
521
- ForgotPasswordAppearance,
522
- ResetPasswordAppearance,
523
- UserButtonProps,
524
- ProtectProps,
525
- ConditionalProps,
526
- InsforgeCallbackProps,
527
- SignInFormProps,
528
- SignUpFormProps,
529
- ForgotPasswordFormProps,
530
- ResetPasswordFormProps,
531
- VerifyEmailStatusProps,
532
- AuthFormFieldProps,
533
- OAuthProvider,
534
- EmailAuthConfig,
535
- InsforgeProviderProps,
536
- GetInsforgeRoutesConfig,
537
- } from '@insforge/react';
538
- ```
539
-
540
- ---
541
-
542
- ## OAuth Providers
543
-
544
- Built-in support for 10+ OAuth providers:
545
- - Google
546
- - GitHub
547
- - Discord
548
- - Apple
549
- - Microsoft
550
- - Facebook
551
- - LinkedIn
552
- - Instagram
553
- - TikTok
554
- - Spotify
555
- - X (Twitter)
556
-
557
- Providers are auto-detected from your backend configuration.
558
-
559
- ---
560
-
561
- ## Validation Utilities
562
-
563
- ```tsx
564
- import { emailSchema, cn } from '@insforge/react/lib';
565
-
566
- // Validate email with Zod
567
- const result = emailSchema.safeParse('user@example.com');
568
-
569
- // Merge Tailwind classes
570
- const className = cn('px-4 py-2', 'bg-blue-500', conditionalClass);
571
- ```
572
-
573
- ---
574
-
575
- ## Available Atomic Components
576
-
577
- Low-level building blocks for complete customization:
578
-
579
- - `<AuthBranding />` - Insforge branding footer
580
- - `<AuthContainer />` - Main container wrapper
581
- - `<AuthHeader />` - Title and subtitle display
582
- - `<AuthErrorBanner />` - Error message display
583
- - `<AuthFormField />` - Standard input field
584
- - `<AuthPasswordField />` - Password input with features
585
- - `<AuthPasswordStrengthIndicator />` - Password checklist
586
- - `<AuthSubmitButton />` - Submit button with states
587
- - `<AuthLink />` - Call-to-action link
588
- - `<AuthDivider />` - Visual separator
589
- - `<AuthOAuthButton />` - Single OAuth provider button
590
- - `<AuthOAuthProviders />` - Smart OAuth grid
591
- - `<AuthVerificationCodeInput />` - 6-digit OTP input
592
- - `<AuthEmailVerificationStep />` - Email verification step with countdown and resend
593
-
594
- ---
595
-
596
- ## Support
597
-
598
- - **Documentation**: https://docs.insforge.dev
599
- - **GitHub Issues**: https://github.com/InsForge/InsForge/issues
600
- - **Discord Community**: https://discord.com/invite/DvBtaEc9Jz
601
-
602
- ## License
603
-
604
- MIT © Insforge
1
+ # @insforge/react
2
+
3
+ **Complete authentication solution for React applications.** Production-ready components with full business logic included.
4
+
5
+ ## Why @insforge/react?
6
+
7
+ ✅ **5-Minute Setup** - One provider + one line of router config = done
8
+ ✅ **Built-in Auth UI** - Use deployed auth pages (like Next.js middleware)
9
+ ✅ **Framework Agnostic** - Works with any React framework
10
+ ✅ **Full TypeScript** - Complete type safety out of the box
11
+
12
+ ---
13
+
14
+ ## Quick Start
15
+
16
+ Get authentication working in your React app in 5 minutes.
17
+
18
+ ### 1. Install
19
+
20
+ ```bash
21
+ npm install @insforge/react
22
+ # or
23
+ yarn add @insforge/react
24
+ # or
25
+ pnpm add @insforge/react
26
+ ```
27
+
28
+ ### 2. Setup Provider
29
+
30
+ Wrap your app with `InsforgeProvider`:
31
+
32
+ ```tsx
33
+ // src/main.tsx (Vite) or src/index.tsx (CRA)
34
+ import { StrictMode } from 'react';
35
+ import { createRoot } from 'react-dom/client';
36
+ import { InsforgeProvider } from '@insforge/react';
37
+ import '@insforge/react/styles.css';
38
+ import App from './App';
39
+
40
+ createRoot(document.getElementById('root')!).render(
41
+ <StrictMode>
42
+ <InsforgeProvider baseUrl={import.meta.env.VITE_INSFORGE_BASE_URL}>
43
+ <App />
44
+ </InsforgeProvider>
45
+ </StrictMode>
46
+ );
47
+ ```
48
+
49
+ ### 3. Configure Router (Built-in Auth)
50
+
51
+ ```tsx
52
+ // src/App.tsx
53
+ import { createBrowserRouter, RouterProvider } from 'react-router-dom';
54
+ import { getInsforgeRoutes } from '@insforge/react/router';
55
+ import Home from './pages/Home';
56
+ import Dashboard from './pages/Dashboard';
57
+
58
+ const router = createBrowserRouter([
59
+ { path: '/', element: <Home /> },
60
+
61
+ ...getInsforgeRoutes({
62
+ baseUrl: import.meta.env.VITE_INSFORGE_BASE_URL,
63
+ builtInAuth: true
64
+ }),
65
+
66
+ { path: '/dashboard', element: <Dashboard /> }
67
+ ]);
68
+
69
+ export default function App() {
70
+ return <RouterProvider router={router} />;
71
+ }
72
+ ```
73
+
74
+ **What this does:**
75
+ - Visiting `/sign-in` → Redirects to `your-project.insforge.app/auth/sign-in`
76
+ - Visiting `/sign-up` → Redirects to `your-project.insforge.app/auth/sign-up`
77
+ - After authBackend redirects with token in URL → SDK auto-detects and stores token
78
+
79
+ ### 4. Add Auth UI to Your Pages
80
+
81
+ ```tsx
82
+ // src/pages/Home.tsx
83
+ import { SignedIn, SignedOut, UserButton } from '@insforge/react';
84
+
85
+ export default function Home() {
86
+ return (
87
+ <div>
88
+ <nav>
89
+ <SignedOut>
90
+ <a href="/sign-in">Sign In</a>
91
+ </SignedOut>
92
+
93
+ <SignedIn>
94
+ <UserButton afterSignOutUrl="/" />
95
+ </SignedIn>
96
+ </nav>
97
+
98
+ <h1>Welcome to My App!</h1>
99
+ </div>
100
+ );
101
+ }
102
+ ```
103
+
104
+ **That's it!** 🎉 You now have production-ready authentication.
105
+
106
+ ---
107
+
108
+ ## Router Configuration Options
109
+
110
+ ### Built-in Auth (Recommended)
111
+
112
+ Uses your deployed Insforge auth pages (includes all flows):
113
+
114
+ ```tsx
115
+ ...getInsforgeRoutes({
116
+ baseUrl: 'https://your-project.insforge.app',
117
+ builtInAuth: true, // Default
118
+ paths: {
119
+ signIn: '/sign-in', // Sign in page
120
+ signUp: '/sign-up', // Sign up page
121
+ verifyEmail: '/verify-email', // Email verification page
122
+ forgotPassword: '/forgot-password', // Request password reset
123
+ resetPassword: '/reset-password' // Reset password with token
124
+ }
125
+ })
126
+ ```
127
+
128
+ ### Custom UI Components
129
+
130
+ Use package components with your own styling:
131
+
132
+ ```tsx
133
+ import {
134
+ SignIn,
135
+ SignUp,
136
+ ForgotPassword,
137
+ ResetPassword,
138
+ VerifyEmail
139
+ } from '@insforge/react';
140
+
141
+ const router = createBrowserRouter([
142
+ { path: '/', element: <Home /> },
143
+
144
+ // Use package components for complete auth flows
145
+ { path: '/sign-in', element: <SignIn afterSignInUrl="/dashboard" /> },
146
+ { path: '/sign-up', element: <SignUp afterSignUpUrl="/dashboard" /> },
147
+ { path: '/forgot-password', element: <ForgotPassword backToSignInUrl="/sign-in" /> },
148
+ { path: '/reset-password', element: <ResetPassword token={searchParams.get('token')} /> },
149
+ { path: '/verify-email', element: <VerifyEmail token={searchParams.get('token')} /> }
150
+ ]);
151
+ ```
152
+
153
+ ### Fully Custom UI
154
+
155
+ Build your own auth pages from scratch:
156
+
157
+ ```tsx
158
+ import { useAuth } from '@insforge/react';
159
+
160
+ function CustomSignIn() {
161
+ const { signIn } = useAuth();
162
+
163
+ const handleSubmit = async (e) => {
164
+ e.preventDefault();
165
+ await signIn(email, password);
166
+ navigate('/dashboard');
167
+ };
168
+
169
+ return <form onSubmit={handleSubmit}>...</form>;
170
+ }
171
+ ```
172
+
173
+ ---
174
+
175
+ ## Core Features
176
+
177
+ ### Components
178
+
179
+ **Pre-built with Business Logic:**
180
+ - `<SignIn />` - Complete sign-in with email/password & OAuth
181
+ - `<SignUp />` - Registration with password validation & email verification
182
+ - `<ForgotPassword />` - Request password reset with email validation
183
+ - `<ResetPassword />` - Reset password with token validation
184
+ - `<VerifyEmail />` - Verify email with automatic token handling
185
+ - `<UserButton />` - User dropdown with sign-out
186
+ - `<Protect />` - Route protection wrapper
187
+ - `<SignedIn>` / `<SignedOut>` - Conditional rendering
188
+
189
+ **Form Components (Pure UI):**
190
+ - `<SignInForm />` - Sign-in UI without logic
191
+ - `<SignUpForm />` - Sign-up UI without logic
192
+ - `<ForgotPasswordForm />` - Password reset request UI
193
+ - `<ResetPasswordForm />` - Password reset with token UI
194
+ - `<VerifyEmailStatus />` - Email verification status UI
195
+
196
+ **Atomic Components (14 total):**
197
+ - `<AuthContainer />`, `<AuthHeader />`, `<AuthFormField />`, `<AuthPasswordField />`, `<AuthEmailVerificationStep />`, etc.
198
+
199
+ ### Hooks
200
+
201
+ ```tsx
202
+ const { signIn, signUp, signOut, isSignedIn, isLoaded } = useAuth();
203
+ const { user, updateUser, isLoaded } = useUser();
204
+ const { oauthProviders, authConfig, isLoaded } = usePublicAuthConfig();
205
+ ```
206
+
207
+ ---
208
+
209
+ ## Customization
210
+
211
+ ### Text Customization
212
+
213
+ All components support full text customization:
214
+
215
+ ```tsx
216
+ <SignIn
217
+ title="Welcome Back!"
218
+ subtitle="We're happy to see you again"
219
+ emailLabel="Your Email Address"
220
+ emailPlaceholder="you@company.com"
221
+ passwordLabel="Your Password"
222
+ submitButtonText="Login Now"
223
+ loadingButtonText="Signing you in..."
224
+ signUpText="New to our platform?"
225
+ signUpLinkText="Create an account"
226
+ dividerText="or continue with"
227
+ />
228
+
229
+ <ForgotPassword
230
+ title="Reset Your Password"
231
+ subtitle="Enter your email to receive a reset code"
232
+ emailLabel="Email Address"
233
+ submitButtonText="Send Reset Code"
234
+ backToSignInText="Remember your password?"
235
+ successTitle="Check Your Email"
236
+ successMessage="We've sent a reset code to your inbox"
237
+ />
238
+ ```
239
+ ---
240
+
241
+ ## Advanced Usage
242
+
243
+ ### Complete Component with Custom Logic
244
+
245
+ ```tsx
246
+ import { SignInForm, useAuth } from '@insforge/react';
247
+ import { useState } from 'react';
248
+
249
+ function CustomSignIn() {
250
+ const { signIn } = useAuth();
251
+ const [email, setEmail] = useState('');
252
+ const [password, setPassword] = useState('');
253
+ const [error, setError] = useState('');
254
+ const [loading, setLoading] = useState(false);
255
+
256
+ const handleSubmit = async (e: React.FormEvent) => {
257
+ e.preventDefault();
258
+ setLoading(true);
259
+ setError('');
260
+
261
+ try {
262
+ await signIn(email, password);
263
+ // Custom success logic
264
+ } catch (err) {
265
+ setError(err.message);
266
+ } finally {
267
+ setLoading(false);
268
+ }
269
+ };
270
+
271
+ return (
272
+ <SignInForm
273
+ email={email}
274
+ password={password}
275
+ onEmailChange={setEmail}
276
+ onPasswordChange={setPassword}
277
+ onSubmit={handleSubmit}
278
+ error={error}
279
+ loading={loading}
280
+ availableProviders={['google', 'github']}
281
+ onOAuthClick={(provider) => {
282
+ // Custom OAuth logic
283
+ }}
284
+ />
285
+ );
286
+ }
287
+ ```
288
+
289
+ ### Build from Atomic Components
290
+
291
+ ```tsx
292
+ import {
293
+ AuthContainer,
294
+ AuthHeader,
295
+ AuthFormField,
296
+ AuthPasswordField,
297
+ AuthSubmitButton,
298
+ AuthErrorBanner,
299
+ AuthDivider,
300
+ AuthOAuthProviders,
301
+ AuthLink,
302
+ } from '@insforge/react';
303
+
304
+ function CompletelyCustomAuth() {
305
+ return (
306
+ <AuthContainer>
307
+ <AuthHeader
308
+ title="Welcome to MyApp"
309
+ subtitle="Sign in to continue"
310
+ />
311
+
312
+ <AuthErrorBanner error={error} />
313
+
314
+ <form onSubmit={handleSubmit}>
315
+ <AuthFormField
316
+ id="email"
317
+ type="email"
318
+ label="Email"
319
+ value={email}
320
+ onChange={(e) => setEmail(e.target.value)}
321
+ />
322
+
323
+ <AuthPasswordField
324
+ id="password"
325
+ label="Password"
326
+ value={password}
327
+ onChange={(e) => setPassword(e.target.value)}
328
+ authConfig={config}
329
+ showStrengthIndicator
330
+ />
331
+
332
+ <AuthSubmitButton isLoading={loading}>
333
+ Sign In
334
+ </AuthSubmitButton>
335
+ </form>
336
+
337
+ <AuthDivider text="or" />
338
+
339
+ <AuthOAuthProviders
340
+ providers={['google', 'github', 'discord']}
341
+ onClick={handleOAuth}
342
+ loading={oauthLoading}
343
+ />
344
+
345
+ <AuthLink
346
+ text="Don't have an account?"
347
+ linkText="Sign up"
348
+ href="/sign-up"
349
+ />
350
+ </AuthContainer>
351
+ );
352
+ }
353
+ ```
354
+
355
+ ### Route Protection
356
+
357
+ ```tsx
358
+ import { Protect } from '@insforge/react';
359
+
360
+ function Dashboard() {
361
+ return (
362
+ <div>
363
+ <h1>Dashboard</h1>
364
+
365
+ {/* Simple protection */}
366
+ <Protect redirectTo="/sign-in">
367
+ <UserContent />
368
+ </Protect>
369
+
370
+ {/* Role-based protection */}
371
+ <Protect
372
+ redirectTo="/unauthorized"
373
+ condition={(user) => user.role === 'admin'}
374
+ >
375
+ <AdminPanel />
376
+ </Protect>
377
+ </div>
378
+ );
379
+ }
380
+ ```
381
+
382
+ ---
383
+
384
+ ## TypeScript
385
+
386
+ Full TypeScript support with exported types:
387
+
388
+ ```tsx
389
+ import type {
390
+ InsforgeUser,
391
+ SignInProps,
392
+ SignUpProps,
393
+ ForgotPasswordProps,
394
+ ResetPasswordProps,
395
+ VerifyEmailProps,
396
+ UserButtonProps,
397
+ ProtectProps,
398
+ ConditionalProps,
399
+ SignInFormProps,
400
+ SignUpFormProps,
401
+ ForgotPasswordFormProps,
402
+ ResetPasswordFormProps,
403
+ VerifyEmailStatusProps,
404
+ AuthFormFieldProps,
405
+ OAuthProvider,
406
+ AuthConfig,
407
+ InsforgeProviderProps,
408
+ GetInsforgeRoutesConfig,
409
+ } from '@insforge/react';
410
+ ```
411
+
412
+ ---
413
+
414
+ ## OAuth Providers
415
+
416
+ Built-in support for 10+ OAuth providers:
417
+ - Google
418
+ - GitHub
419
+ - Discord
420
+ - Apple
421
+ - Microsoft
422
+ - Facebook
423
+ - LinkedIn
424
+ - Instagram
425
+ - TikTok
426
+ - Spotify
427
+ - X (Twitter)
428
+
429
+ Providers are auto-detected from your backend configuration.
430
+
431
+ ---
432
+
433
+ ## Validation Utilities
434
+
435
+ ```tsx
436
+ import { emailSchema, cn } from '@insforge/react/lib';
437
+
438
+ // Validate email with Zod
439
+ const result = emailSchema.safeParse('user@example.com');
440
+
441
+ // Merge Tailwind classes
442
+ const className = cn('px-4 py-2', 'bg-blue-500', conditionalClass);
443
+ ```
444
+
445
+ ---
446
+
447
+ ## Available Atomic Components
448
+
449
+ Low-level building blocks for complete customization:
450
+
451
+ - `<AuthBranding />` - Insforge branding footer
452
+ - `<AuthContainer />` - Main container wrapper
453
+ - `<AuthHeader />` - Title and subtitle display
454
+ - `<AuthErrorBanner />` - Error message display
455
+ - `<AuthFormField />` - Standard input field
456
+ - `<AuthPasswordField />` - Password input with features
457
+ - `<AuthPasswordStrengthIndicator />` - Password checklist
458
+ - `<AuthSubmitButton />` - Submit button with states
459
+ - `<AuthLink />` - Call-to-action link
460
+ - `<AuthDivider />` - Visual separator
461
+ - `<AuthOAuthButton />` - Single OAuth provider button
462
+ - `<AuthOAuthProviders />` - Smart OAuth grid
463
+ - `<AuthVerificationCodeInput />` - 6-digit OTP input
464
+ - `<AuthEmailVerificationStep />` - Email verification step with countdown and resend
465
+
466
+ ---
467
+
468
+ ## Support
469
+
470
+ - **Documentation**: https://docs.insforge.dev
471
+ - **GitHub Issues**: https://github.com/InsForge/InsForge/issues
472
+ - **Discord Community**: https://discord.com/invite/DvBtaEc9Jz
473
+
474
+ ## License
475
+
476
+ MIT © Insforge