@insforge/react 0.5.0 → 0.5.2
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.
- package/README.md +426 -439
- package/dist/atoms.cjs +23 -1
- package/dist/atoms.cjs.map +1 -1
- package/dist/atoms.js +23 -1
- package/dist/atoms.js.map +1 -1
- package/dist/components.cjs +23 -1
- package/dist/components.cjs.map +1 -1
- package/dist/components.js +23 -1
- package/dist/components.js.map +1 -1
- package/dist/forms.cjs +23 -1
- package/dist/forms.cjs.map +1 -1
- package/dist/forms.js +23 -1
- package/dist/forms.js.map +1 -1
- package/dist/hooks.cjs +23 -1
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.js +23 -1
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +23 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +23 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,439 +1,426 @@
|
|
|
1
|
-
# @insforge/react
|
|
2
|
-
|
|
3
|
-
**
|
|
4
|
-
|
|
5
|
-
## Why @insforge/react?
|
|
6
|
-
|
|
7
|
-
✅ **
|
|
8
|
-
✅ **
|
|
9
|
-
✅ **
|
|
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
|
-
**Required Dependencies:**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
createRoot
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
###
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
- `<
|
|
196
|
-
- `<
|
|
197
|
-
- `<
|
|
198
|
-
- `<
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
- `<
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
###
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
error={error}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
<
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
<
|
|
348
|
-
</
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
-
|
|
395
|
-
-
|
|
396
|
-
-
|
|
397
|
-
-
|
|
398
|
-
-
|
|
399
|
-
-
|
|
400
|
-
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
-
|
|
421
|
-
-
|
|
422
|
-
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
- `<AuthEmailVerificationStep />` - Email verification step with countdown and resend
|
|
428
|
-
|
|
429
|
-
---
|
|
430
|
-
|
|
431
|
-
## Support
|
|
432
|
-
|
|
433
|
-
- **Documentation**: https://docs.insforge.dev
|
|
434
|
-
- **GitHub Issues**: https://github.com/InsForge/InsForge/issues
|
|
435
|
-
- **Discord Community**: https://discord.com/invite/DvBtaEc9Jz
|
|
436
|
-
|
|
437
|
-
## License
|
|
438
|
-
|
|
439
|
-
MIT © Insforge
|
|
1
|
+
# @insforge/react
|
|
2
|
+
|
|
3
|
+
**Framework-agnostic authentication solution for React applications.** Production-ready components with full business logic included.
|
|
4
|
+
|
|
5
|
+
## Why @insforge/react?
|
|
6
|
+
|
|
7
|
+
✅ **Framework Agnostic** - Works with any React setup (Vite, CRA, or no bundler)
|
|
8
|
+
✅ **Zero Router Dependencies** - Use with any routing solution or none at all
|
|
9
|
+
✅ **Production Ready** - Complete auth flows with business logic included
|
|
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
|
+
**Required Peer Dependencies:**
|
|
29
|
+
```bash
|
|
30
|
+
npm install react@^19.0.0 react-dom@^19.0.0
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
#### Environment Variables
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# .env
|
|
38
|
+
VITE_INSFORGE_BASE_URL=https://your-project.insforge.app/
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 2. Setup Provider
|
|
42
|
+
|
|
43
|
+
Wrap your app with `InsforgeProvider`:
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
// src/main.tsx (Vite) or src/index.tsx (CRA)
|
|
47
|
+
import { StrictMode } from 'react';
|
|
48
|
+
import { createRoot } from 'react-dom/client';
|
|
49
|
+
import { InsforgeProvider } from '@insforge/react';
|
|
50
|
+
import App from './App';
|
|
51
|
+
|
|
52
|
+
createRoot(document.getElementById('root')!).render(
|
|
53
|
+
<StrictMode>
|
|
54
|
+
<InsforgeProvider baseUrl={import.meta.env.VITE_INSFORGE_BASE_URL} afterSignInUrl="/dashboard">
|
|
55
|
+
<App />
|
|
56
|
+
</InsforgeProvider>
|
|
57
|
+
</StrictMode>
|
|
58
|
+
);
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 3. Use Components & Hooks
|
|
62
|
+
|
|
63
|
+
Now you can use authentication components and hooks anywhere in your app:
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
// src/App.tsx
|
|
67
|
+
import { SignIn, SignedIn, SignedOut, UserButton, useAuth } from '@insforge/react';
|
|
68
|
+
|
|
69
|
+
export default function App() {
|
|
70
|
+
const { isSignedIn, isLoaded } = useAuth();
|
|
71
|
+
|
|
72
|
+
if (!isLoaded) {
|
|
73
|
+
return <div>Loading...</div>;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<div>
|
|
78
|
+
<SignedOut>
|
|
79
|
+
<SignIn />
|
|
80
|
+
</SignedOut>
|
|
81
|
+
|
|
82
|
+
<SignedIn>
|
|
83
|
+
<nav>
|
|
84
|
+
<UserButton afterSignOutUrl="/" />
|
|
85
|
+
</nav>
|
|
86
|
+
<h1>Welcome to your dashboard!</h1>
|
|
87
|
+
</SignedIn>
|
|
88
|
+
</div>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**That's it!** 🎉 You now have production-ready authentication.
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Usage Patterns
|
|
98
|
+
|
|
99
|
+
### Option 1: Pre-built Components (Fastest)
|
|
100
|
+
|
|
101
|
+
Use complete auth flows with built-in UI and logic:
|
|
102
|
+
|
|
103
|
+
```tsx
|
|
104
|
+
import { SignIn, SignUp, ForgotPassword, ResetPassword } from '@insforge/react';
|
|
105
|
+
|
|
106
|
+
// In your app
|
|
107
|
+
<SignIn /> // Complete sign-in flow
|
|
108
|
+
<SignUp /> // Complete sign-up flow with email verification
|
|
109
|
+
<ForgotPassword /> // Password reset request + verification
|
|
110
|
+
<ResetPassword /> // Reset password with token (from URL params)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Option 2: Form Components (UI Only)
|
|
114
|
+
|
|
115
|
+
Use UI components and add your own logic:
|
|
116
|
+
|
|
117
|
+
```tsx
|
|
118
|
+
import { SignInForm, useAuth } from '@insforge/react';
|
|
119
|
+
import { useState } from 'react';
|
|
120
|
+
|
|
121
|
+
function CustomSignIn() {
|
|
122
|
+
const { signIn } = useAuth();
|
|
123
|
+
const [email, setEmail] = useState('');
|
|
124
|
+
const [password, setPassword] = useState('');
|
|
125
|
+
const [error, setError] = useState('');
|
|
126
|
+
const [loading, setLoading] = useState(false);
|
|
127
|
+
|
|
128
|
+
const handleSubmit = async (e) => {
|
|
129
|
+
e.preventDefault();
|
|
130
|
+
setLoading(true);
|
|
131
|
+
const result = await signIn(email, password);
|
|
132
|
+
if ('error' in result) {
|
|
133
|
+
setError(result.error);
|
|
134
|
+
}
|
|
135
|
+
setLoading(false);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
return (
|
|
139
|
+
<SignInForm
|
|
140
|
+
email={email}
|
|
141
|
+
password={password}
|
|
142
|
+
onEmailChange={setEmail}
|
|
143
|
+
onPasswordChange={setPassword}
|
|
144
|
+
onSubmit={handleSubmit}
|
|
145
|
+
error={error}
|
|
146
|
+
loading={loading}
|
|
147
|
+
/>
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Option 3: Hooks Only (Headless)
|
|
153
|
+
|
|
154
|
+
Build completely custom UI using authentication hooks:
|
|
155
|
+
|
|
156
|
+
```tsx
|
|
157
|
+
import { useAuth } from '@insforge/react';
|
|
158
|
+
|
|
159
|
+
function CustomAuthForm() {
|
|
160
|
+
const { signIn, signUp, isLoaded } = useAuth();
|
|
161
|
+
|
|
162
|
+
const handleLogin = async (email: string, password: string) => {
|
|
163
|
+
const result = await signIn(email, password);
|
|
164
|
+
if ('error' in result) {
|
|
165
|
+
console.error(result.error);
|
|
166
|
+
} else {
|
|
167
|
+
console.log('Signed in!');
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
return <form>...your custom UI...</form>;
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## Core Features
|
|
178
|
+
|
|
179
|
+
### Components
|
|
180
|
+
|
|
181
|
+
**Pre-built with Business Logic:**
|
|
182
|
+
|
|
183
|
+
- `<SignIn />` - Complete sign-in with email/password & OAuth
|
|
184
|
+
- `<SignUp />` - Registration with password validation & email verification
|
|
185
|
+
- `<ForgotPassword />` - Request password reset with email validation
|
|
186
|
+
- `<ResetPassword />` - Reset password with token validation
|
|
187
|
+
- `<VerifyEmail />` - Verify email with automatic token handling
|
|
188
|
+
- `<UserButton />` - User dropdown with sign-out
|
|
189
|
+
- `<Protect />` - Route protection wrapper
|
|
190
|
+
- `<SignedIn>` / `<SignedOut>` - Conditional rendering
|
|
191
|
+
|
|
192
|
+
**Form Components (Pure UI):**
|
|
193
|
+
|
|
194
|
+
- `<SignInForm />` - Sign-in UI without logic
|
|
195
|
+
- `<SignUpForm />` - Sign-up UI without logic
|
|
196
|
+
- `<ForgotPasswordForm />` - Password reset request UI
|
|
197
|
+
- `<ResetPasswordForm />` - Password reset with token UI
|
|
198
|
+
- `<VerifyEmailStatus />` - Email verification status UI
|
|
199
|
+
|
|
200
|
+
**Atomic Components (14 total):**
|
|
201
|
+
|
|
202
|
+
- `<AuthContainer />`, `<AuthHeader />`, `<AuthFormField />`, `<AuthPasswordField />`, `<AuthEmailVerificationStep />`, etc.
|
|
203
|
+
|
|
204
|
+
### Hooks
|
|
205
|
+
|
|
206
|
+
```tsx
|
|
207
|
+
const { signIn, signUp, signOut, isSignedIn, isLoaded } = useAuth();
|
|
208
|
+
const { user, updateUser, isLoaded } = useUser();
|
|
209
|
+
const { oauthProviders, authConfig, isLoaded } = usePublicAuthConfig();
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## Customization
|
|
215
|
+
|
|
216
|
+
### Text Customization
|
|
217
|
+
|
|
218
|
+
All components support full text customization:
|
|
219
|
+
|
|
220
|
+
```tsx
|
|
221
|
+
<SignIn
|
|
222
|
+
title="Welcome Back!"
|
|
223
|
+
subtitle="We're happy to see you again"
|
|
224
|
+
emailLabel="Your Email Address"
|
|
225
|
+
emailPlaceholder="you@company.com"
|
|
226
|
+
passwordLabel="Your Password"
|
|
227
|
+
submitButtonText="Login Now"
|
|
228
|
+
loadingButtonText="Signing you in..."
|
|
229
|
+
signUpText="New to our platform?"
|
|
230
|
+
signUpLinkText="Create an account"
|
|
231
|
+
dividerText="or continue with"
|
|
232
|
+
/>
|
|
233
|
+
|
|
234
|
+
<ForgotPassword
|
|
235
|
+
title="Reset Your Password"
|
|
236
|
+
subtitle="Enter your email to receive a reset code"
|
|
237
|
+
emailLabel="Email Address"
|
|
238
|
+
submitButtonText="Send Reset Code"
|
|
239
|
+
backToSignInText="Remember your password?"
|
|
240
|
+
successTitle="Check Your Email"
|
|
241
|
+
successMessage="We've sent a reset code to your inbox"
|
|
242
|
+
/>
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## Advanced Usage
|
|
248
|
+
|
|
249
|
+
### Conditional Rendering
|
|
250
|
+
|
|
251
|
+
Control what users see based on auth state:
|
|
252
|
+
|
|
253
|
+
```tsx
|
|
254
|
+
import { SignedIn, SignedOut, Protect } from '@insforge/react';
|
|
255
|
+
|
|
256
|
+
function App() {
|
|
257
|
+
return (
|
|
258
|
+
<>
|
|
259
|
+
<SignedOut>
|
|
260
|
+
<SignIn />
|
|
261
|
+
</SignedOut>
|
|
262
|
+
|
|
263
|
+
<SignedIn>
|
|
264
|
+
<Dashboard />
|
|
265
|
+
</SignedIn>
|
|
266
|
+
|
|
267
|
+
{/* Or use Protect for specific sections */}
|
|
268
|
+
<Protect redirectTo="/sign-in">
|
|
269
|
+
<ProtectedContent />
|
|
270
|
+
</Protect>
|
|
271
|
+
</>
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Build from Atomic Components
|
|
277
|
+
|
|
278
|
+
```tsx
|
|
279
|
+
import {
|
|
280
|
+
AuthContainer,
|
|
281
|
+
AuthHeader,
|
|
282
|
+
AuthFormField,
|
|
283
|
+
AuthPasswordField,
|
|
284
|
+
AuthSubmitButton,
|
|
285
|
+
AuthErrorBanner,
|
|
286
|
+
AuthDivider,
|
|
287
|
+
AuthOAuthProviders,
|
|
288
|
+
AuthLink,
|
|
289
|
+
} from '@insforge/react';
|
|
290
|
+
|
|
291
|
+
function CompletelyCustomAuth() {
|
|
292
|
+
return (
|
|
293
|
+
<AuthContainer>
|
|
294
|
+
<AuthHeader title="Welcome to MyApp" subtitle="Sign in to continue" />
|
|
295
|
+
|
|
296
|
+
<AuthErrorBanner error={error} />
|
|
297
|
+
|
|
298
|
+
<form onSubmit={handleSubmit}>
|
|
299
|
+
<AuthFormField
|
|
300
|
+
id="email"
|
|
301
|
+
type="email"
|
|
302
|
+
label="Email"
|
|
303
|
+
value={email}
|
|
304
|
+
onChange={(e) => setEmail(e.target.value)}
|
|
305
|
+
/>
|
|
306
|
+
|
|
307
|
+
<AuthPasswordField
|
|
308
|
+
id="password"
|
|
309
|
+
label="Password"
|
|
310
|
+
value={password}
|
|
311
|
+
onChange={(e) => setPassword(e.target.value)}
|
|
312
|
+
authConfig={config}
|
|
313
|
+
showStrengthIndicator
|
|
314
|
+
/>
|
|
315
|
+
|
|
316
|
+
<AuthSubmitButton isLoading={loading}>Sign In</AuthSubmitButton>
|
|
317
|
+
</form>
|
|
318
|
+
|
|
319
|
+
<AuthDivider text="or" />
|
|
320
|
+
|
|
321
|
+
<AuthOAuthProviders
|
|
322
|
+
providers={['google', 'github', 'discord']}
|
|
323
|
+
onClick={handleOAuth}
|
|
324
|
+
loading={oauthLoading}
|
|
325
|
+
/>
|
|
326
|
+
|
|
327
|
+
<AuthLink text="Don't have an account?" linkText="Sign up" href="/sign-up" />
|
|
328
|
+
</AuthContainer>
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
### Content Protection
|
|
334
|
+
|
|
335
|
+
Protect specific content or sections:
|
|
336
|
+
|
|
337
|
+
```tsx
|
|
338
|
+
import { Protect } from '@insforge/react';
|
|
339
|
+
|
|
340
|
+
function Dashboard() {
|
|
341
|
+
return (
|
|
342
|
+
<div>
|
|
343
|
+
<h1>Dashboard</h1>
|
|
344
|
+
|
|
345
|
+
{/* Simple protection - shows nothing if not signed in */}
|
|
346
|
+
<Protect>
|
|
347
|
+
<UserContent />
|
|
348
|
+
</Protect>
|
|
349
|
+
|
|
350
|
+
{/* Custom condition - e.g., role-based */}
|
|
351
|
+
<Protect condition={(user) => user.email.endsWith('@admin.com')}>
|
|
352
|
+
<AdminPanel />
|
|
353
|
+
</Protect>
|
|
354
|
+
</div>
|
|
355
|
+
);
|
|
356
|
+
}
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
> **Note:** `<Protect>` is for conditional rendering only. For route-level protection, use your router's authentication guards with `useAuth()` hook.
|
|
360
|
+
|
|
361
|
+
---
|
|
362
|
+
|
|
363
|
+
## OAuth Providers
|
|
364
|
+
|
|
365
|
+
Built-in support for 10+ OAuth providers:
|
|
366
|
+
|
|
367
|
+
- Google
|
|
368
|
+
- GitHub
|
|
369
|
+
- Discord
|
|
370
|
+
- Apple
|
|
371
|
+
- Microsoft
|
|
372
|
+
- Facebook
|
|
373
|
+
- LinkedIn
|
|
374
|
+
- Instagram
|
|
375
|
+
- TikTok
|
|
376
|
+
- Spotify
|
|
377
|
+
- X (Twitter)
|
|
378
|
+
|
|
379
|
+
Providers are auto-detected from your backend configuration.
|
|
380
|
+
|
|
381
|
+
---
|
|
382
|
+
|
|
383
|
+
## Available Atomic Components
|
|
384
|
+
|
|
385
|
+
Low-level building blocks for complete customization:
|
|
386
|
+
|
|
387
|
+
- `<AuthBranding />` - Insforge branding footer
|
|
388
|
+
- `<AuthContainer />` - Main container wrapper
|
|
389
|
+
- `<AuthHeader />` - Title and subtitle display
|
|
390
|
+
- `<AuthErrorBanner />` - Error message display
|
|
391
|
+
- `<AuthFormField />` - Standard input field
|
|
392
|
+
- `<AuthPasswordField />` - Password input with features
|
|
393
|
+
- `<AuthPasswordStrengthIndicator />` - Password checklist
|
|
394
|
+
- `<AuthSubmitButton />` - Submit button with states
|
|
395
|
+
- `<AuthLink />` - Call-to-action link
|
|
396
|
+
- `<AuthDivider />` - Visual separator
|
|
397
|
+
- `<AuthOAuthButton />` - Single OAuth provider button
|
|
398
|
+
- `<AuthOAuthProviders />` - Smart OAuth grid
|
|
399
|
+
- `<AuthVerificationCodeInput />` - 6-digit OTP input
|
|
400
|
+
- `<AuthEmailVerificationStep />` - Email verification step with countdown and resend
|
|
401
|
+
|
|
402
|
+
---
|
|
403
|
+
|
|
404
|
+
## Framework Integration
|
|
405
|
+
|
|
406
|
+
### Next.js
|
|
407
|
+
|
|
408
|
+
For Next.js App Router with full SSR support:
|
|
409
|
+
|
|
410
|
+
```bash
|
|
411
|
+
npm install @insforge/nextjs
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
See [@insforge/nextjs documentation](https://github.com/InsForge/InsForge/tree/main/packages/nextjs)
|
|
415
|
+
|
|
416
|
+
---
|
|
417
|
+
|
|
418
|
+
## Support
|
|
419
|
+
|
|
420
|
+
- **Documentation**: https://docs.insforge.dev
|
|
421
|
+
- **GitHub Issues**: https://github.com/InsForge/InsForge/issues
|
|
422
|
+
- **Discord Community**: https://discord.com/invite/DvBtaEc9Jz
|
|
423
|
+
|
|
424
|
+
## License
|
|
425
|
+
|
|
426
|
+
MIT © Insforge
|