svelte-firekit 0.0.25 → 0.1.0
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 +445 -213
- package/dist/components/Collection.svelte +150 -0
- package/dist/components/Collection.svelte.d.ts +27 -0
- package/dist/components/Ddoc.svelte +131 -0
- package/dist/components/Ddoc.svelte.d.ts +28 -0
- package/dist/components/Node.svelte +97 -0
- package/dist/components/Node.svelte.d.ts +23 -0
- package/dist/components/auth-guard.svelte +89 -0
- package/dist/components/auth-guard.svelte.d.ts +26 -0
- package/dist/components/custom-guard.svelte +122 -0
- package/dist/components/custom-guard.svelte.d.ts +31 -0
- package/dist/components/download-url.svelte +92 -0
- package/dist/components/download-url.svelte.d.ts +19 -0
- package/dist/components/firebase-app.svelte +30 -0
- package/dist/components/firebase-app.svelte.d.ts +7 -0
- package/dist/components/node-list.svelte +102 -0
- package/dist/components/node-list.svelte.d.ts +27 -0
- package/dist/components/signed-in.svelte +42 -0
- package/dist/components/signed-in.svelte.d.ts +11 -0
- package/dist/components/signed-out.svelte +42 -0
- package/dist/components/signed-out.svelte.d.ts +11 -0
- package/dist/components/storage-list.svelte +97 -0
- package/dist/components/storage-list.svelte.d.ts +26 -0
- package/dist/components/upload-task.svelte +108 -0
- package/dist/components/upload-task.svelte.d.ts +24 -0
- package/dist/config.js +17 -39
- package/dist/firebase.d.ts +43 -21
- package/dist/firebase.js +121 -35
- package/dist/index.d.ts +21 -13
- package/dist/index.js +27 -15
- package/dist/services/auth.d.ts +389 -0
- package/dist/services/auth.js +824 -0
- package/dist/services/collection.svelte.d.ts +286 -0
- package/dist/services/collection.svelte.js +871 -0
- package/dist/services/document.svelte.d.ts +288 -0
- package/dist/services/document.svelte.js +555 -0
- package/dist/services/mutations.d.ts +336 -0
- package/dist/services/mutations.js +1079 -0
- package/dist/services/presence.svelte.d.ts +141 -0
- package/dist/services/presence.svelte.js +727 -0
- package/dist/{realtime → services}/realtime.svelte.d.ts +3 -1
- package/dist/{realtime → services}/realtime.svelte.js +13 -7
- package/dist/services/storage.svelte.d.ts +257 -0
- package/dist/services/storage.svelte.js +374 -0
- package/dist/services/user.svelte.d.ts +290 -0
- package/dist/services/user.svelte.js +533 -0
- package/dist/types/auth.d.ts +158 -0
- package/dist/types/auth.js +106 -0
- package/dist/types/collection.d.ts +360 -0
- package/dist/types/collection.js +167 -0
- package/dist/types/document.d.ts +342 -0
- package/dist/types/document.js +148 -0
- package/dist/types/firebase.d.ts +44 -0
- package/dist/types/firebase.js +33 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.js +4 -0
- package/dist/types/mutations.d.ts +387 -0
- package/dist/types/mutations.js +205 -0
- package/dist/types/presence.d.ts +282 -0
- package/dist/types/presence.js +80 -0
- package/dist/utils/errors.d.ts +21 -0
- package/dist/utils/errors.js +35 -0
- package/dist/utils/firestore.d.ts +9 -0
- package/dist/utils/firestore.js +33 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/providers.d.ts +16 -0
- package/dist/utils/providers.js +30 -0
- package/dist/utils/user.d.ts +8 -0
- package/dist/utils/user.js +29 -0
- package/package.json +65 -65
- package/dist/auth/auth.d.ts +0 -117
- package/dist/auth/auth.js +0 -194
- package/dist/auth/presence.svelte.d.ts +0 -139
- package/dist/auth/presence.svelte.js +0 -373
- package/dist/auth/user.svelte.d.ts +0 -112
- package/dist/auth/user.svelte.js +0 -155
- package/dist/firestore/awaitable-doc.svelte.d.ts +0 -141
- package/dist/firestore/awaitable-doc.svelte.js +0 -183
- package/dist/firestore/batch-mutations.svelte.d.ts +0 -140
- package/dist/firestore/batch-mutations.svelte.js +0 -218
- package/dist/firestore/collection-group.svelte.d.ts +0 -78
- package/dist/firestore/collection-group.svelte.js +0 -120
- package/dist/firestore/collection.svelte.d.ts +0 -96
- package/dist/firestore/collection.svelte.js +0 -137
- package/dist/firestore/doc.svelte.d.ts +0 -90
- package/dist/firestore/doc.svelte.js +0 -131
- package/dist/firestore/document-mutations.svelte.d.ts +0 -164
- package/dist/firestore/document-mutations.svelte.js +0 -273
- package/dist/storage/download-url.svelte.d.ts +0 -83
- package/dist/storage/download-url.svelte.js +0 -114
- package/dist/storage/storage-list.svelte.d.ts +0 -89
- package/dist/storage/storage-list.svelte.js +0 -123
- package/dist/storage/upload-task.svelte.d.ts +0 -94
- package/dist/storage/upload-task.svelte.js +0 -138
package/README.md
CHANGED
|
@@ -1,213 +1,445 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
-
|
|
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
|
-
|
|
1
|
+
# Svelte Firekit
|
|
2
|
+
|
|
3
|
+
Svelte Firekit is a powerful Firebase toolkit for SvelteKit applications, providing a comprehensive set of utilities, stores, and components for seamless Firebase integration. Whether you're building a micro SaaS, web application, or any Firebase-powered project, Svelte Firekit streamlines your development process.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install firebase svelte-firekit
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Configuration
|
|
12
|
+
|
|
13
|
+
Svelte Firekit automatically manages your Firebase configuration through environment variables. Create a `.env` file in your project root with the following variables:
|
|
14
|
+
|
|
15
|
+
```env
|
|
16
|
+
PUBLIC_FIREBASE_API_KEY=your_api_key
|
|
17
|
+
PUBLIC_FIREBASE_AUTH_DOMAIN=your_auth_domain
|
|
18
|
+
PUBLIC_FIREBASE_PROJECT_ID=your_project_id
|
|
19
|
+
PUBLIC_FIREBASE_STORAGE_BUCKET=your_storage_bucket
|
|
20
|
+
PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your_messaging_sender_id
|
|
21
|
+
PUBLIC_FIREBASE_APP_ID=your_app_id
|
|
22
|
+
PUBLIC_FIREBASE_MEASUREMENT_ID=your_measurement_id
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The configuration is automatically handled by Firekit - no manual setup required. If any required environment variables are missing, Firekit will throw a helpful error indicating which variables need to be set.
|
|
26
|
+
|
|
27
|
+
## Usage Example
|
|
28
|
+
|
|
29
|
+
Here's a simple example showing how to display the current user's name:
|
|
30
|
+
|
|
31
|
+
```svelte
|
|
32
|
+
<script>
|
|
33
|
+
import { firekitUser } from 'svelte-firekit';
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
Hello {firekitUser.displayName}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The `firekitUser` store provides access to the current user's information and authentication state.
|
|
40
|
+
|
|
41
|
+
## Core Features
|
|
42
|
+
|
|
43
|
+
### 🔥 Firebase Integration
|
|
44
|
+
|
|
45
|
+
- Zero-config Firebase setup through environment variables
|
|
46
|
+
- Automatic initialization and app management
|
|
47
|
+
- Built-in error handling and connection state management
|
|
48
|
+
- Type-safe configuration management
|
|
49
|
+
|
|
50
|
+
### 🔐 Authentication
|
|
51
|
+
|
|
52
|
+
- Complete authentication system with built-in components
|
|
53
|
+
- Support for multiple authentication providers:
|
|
54
|
+
- Email/Password
|
|
55
|
+
- Google
|
|
56
|
+
- GitHub
|
|
57
|
+
- Custom providers
|
|
58
|
+
- User state management and persistence through `firekitUser` store
|
|
59
|
+
|
|
60
|
+
### 📚 Firestore Integration
|
|
61
|
+
|
|
62
|
+
- Reactive data stores for real-time updates
|
|
63
|
+
- Simplified CRUD operations
|
|
64
|
+
- Batch operations and transactions
|
|
65
|
+
- Type-safe document references
|
|
66
|
+
- Automatic data serialization/deserialization
|
|
67
|
+
|
|
68
|
+
### 📦 Storage Management
|
|
69
|
+
|
|
70
|
+
- File upload and download utilities
|
|
71
|
+
- Progress tracking and status updates
|
|
72
|
+
- Storage security rules helpers
|
|
73
|
+
- Image optimization utilities
|
|
74
|
+
|
|
75
|
+
### ⚡ Server-Side Rendering
|
|
76
|
+
|
|
77
|
+
- Full SSR compatibility
|
|
78
|
+
- Hydration support
|
|
79
|
+
- Server-side data fetching
|
|
80
|
+
- SEO-friendly rendering
|
|
81
|
+
|
|
82
|
+
### 🎯 Type Safety
|
|
83
|
+
|
|
84
|
+
- Built with TypeScript
|
|
85
|
+
- Complete type definitions
|
|
86
|
+
- Intelligent autocomplete
|
|
87
|
+
- Runtime type checking
|
|
88
|
+
- Type-safe Firestore operations
|
|
89
|
+
|
|
90
|
+
## Components
|
|
91
|
+
|
|
92
|
+
Svelte Firekit provides a comprehensive set of Svelte components for easy Firebase integration:
|
|
93
|
+
|
|
94
|
+
### 🔧 Core Components
|
|
95
|
+
|
|
96
|
+
#### `FirebaseApp`
|
|
97
|
+
|
|
98
|
+
The root component that initializes Firebase and provides context to child components.
|
|
99
|
+
|
|
100
|
+
```svelte
|
|
101
|
+
<script>
|
|
102
|
+
import { FirebaseApp } from 'svelte-firekit';
|
|
103
|
+
</script>
|
|
104
|
+
|
|
105
|
+
<FirebaseApp let:children>
|
|
106
|
+
<!-- Your app content here -->
|
|
107
|
+
</FirebaseApp>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### 🔐 Authentication Components
|
|
111
|
+
|
|
112
|
+
#### `AuthGuard`
|
|
113
|
+
|
|
114
|
+
Protects routes and content based on authentication state.
|
|
115
|
+
|
|
116
|
+
```svelte
|
|
117
|
+
<script>
|
|
118
|
+
import { AuthGuard } from 'svelte-firekit';
|
|
119
|
+
</script>
|
|
120
|
+
|
|
121
|
+
<AuthGuard requireAuth={true} redirectTo="/login" let:children let:user let:auth let:signOut>
|
|
122
|
+
<h1>Welcome, {user.displayName}!</h1>
|
|
123
|
+
<button on:click={signOut}>Sign Out</button>
|
|
124
|
+
</AuthGuard>
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
#### `SignedIn`
|
|
128
|
+
|
|
129
|
+
Renders content only when a user is signed in.
|
|
130
|
+
|
|
131
|
+
```svelte
|
|
132
|
+
<script>
|
|
133
|
+
import { SignedIn } from 'svelte-firekit';
|
|
134
|
+
</script>
|
|
135
|
+
|
|
136
|
+
<SignedIn let:children let:user>
|
|
137
|
+
<p>Hello, {user.displayName}!</p>
|
|
138
|
+
</SignedIn>
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
#### `SignedOut`
|
|
142
|
+
|
|
143
|
+
Renders content only when no user is signed in.
|
|
144
|
+
|
|
145
|
+
```svelte
|
|
146
|
+
<script>
|
|
147
|
+
import { SignedOut } from 'svelte-firekit';
|
|
148
|
+
</script>
|
|
149
|
+
|
|
150
|
+
<SignedOut let:children let:auth>
|
|
151
|
+
<button on:click={() => signInWithGoogle()}>Sign In</button>
|
|
152
|
+
</SignedOut>
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
#### `CustomGuard`
|
|
156
|
+
|
|
157
|
+
Advanced authentication guard with custom verification checks.
|
|
158
|
+
|
|
159
|
+
```svelte
|
|
160
|
+
<script>
|
|
161
|
+
import { CustomGuard } from 'svelte-firekit';
|
|
162
|
+
|
|
163
|
+
const emailVerificationCheck = (user) => user.emailVerified;
|
|
164
|
+
</script>
|
|
165
|
+
|
|
166
|
+
<CustomGuard
|
|
167
|
+
verificationChecks={[emailVerificationCheck]}
|
|
168
|
+
redirectTo="/verify-email"
|
|
169
|
+
let:children
|
|
170
|
+
let:user
|
|
171
|
+
let:auth
|
|
172
|
+
let:signOut
|
|
173
|
+
>
|
|
174
|
+
<p>Your email is verified!</p>
|
|
175
|
+
</CustomGuard>
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### 📚 Firestore Components
|
|
179
|
+
|
|
180
|
+
#### `Collection`
|
|
181
|
+
|
|
182
|
+
Reactive component for Firestore collections with real-time updates.
|
|
183
|
+
|
|
184
|
+
```svelte
|
|
185
|
+
<script>
|
|
186
|
+
import { Collection } from 'svelte-firekit';
|
|
187
|
+
</script>
|
|
188
|
+
|
|
189
|
+
<Collection ref="users" let:children let:data let:ref let:firestore let:count>
|
|
190
|
+
{#each data as user}
|
|
191
|
+
<div>{user.name}</div>
|
|
192
|
+
{/each}
|
|
193
|
+
<p>Total users: {count}</p>
|
|
194
|
+
</Collection>
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
#### `Ddoc`
|
|
198
|
+
|
|
199
|
+
Reactive component for individual Firestore documents.
|
|
200
|
+
|
|
201
|
+
```svelte
|
|
202
|
+
<script>
|
|
203
|
+
import { Ddoc } from 'svelte-firekit';
|
|
204
|
+
</script>
|
|
205
|
+
|
|
206
|
+
<Ddoc ref="users/123" let:children let:data let:ref let:firestore>
|
|
207
|
+
{#if data}
|
|
208
|
+
<h1>{data.name}</h1>
|
|
209
|
+
<p>{data.email}</p>
|
|
210
|
+
{/if}
|
|
211
|
+
</Ddoc>
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### 📦 Storage Components
|
|
215
|
+
|
|
216
|
+
#### `UploadTask`
|
|
217
|
+
|
|
218
|
+
Handles file uploads with progress tracking.
|
|
219
|
+
|
|
220
|
+
```svelte
|
|
221
|
+
<script>
|
|
222
|
+
import { UploadTask } from 'svelte-firekit';
|
|
223
|
+
|
|
224
|
+
let file;
|
|
225
|
+
</script>
|
|
226
|
+
|
|
227
|
+
<input type="file" bind:files={file} />
|
|
228
|
+
|
|
229
|
+
<UploadTask
|
|
230
|
+
ref="images/{file.name}"
|
|
231
|
+
data={file}
|
|
232
|
+
let:children
|
|
233
|
+
let:snapshot
|
|
234
|
+
let:task
|
|
235
|
+
let:progress
|
|
236
|
+
let:storage
|
|
237
|
+
>
|
|
238
|
+
<div>Upload Progress: {progress}%</div>
|
|
239
|
+
{#if snapshot?.state === 'success'}
|
|
240
|
+
<p>Upload complete!</p>
|
|
241
|
+
{/if}
|
|
242
|
+
</UploadTask>
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
#### `DownloadUrl`
|
|
246
|
+
|
|
247
|
+
Retrieves download URLs for storage files.
|
|
248
|
+
|
|
249
|
+
```svelte
|
|
250
|
+
<script>
|
|
251
|
+
import { DownloadUrl } from 'svelte-firekit';
|
|
252
|
+
</script>
|
|
253
|
+
|
|
254
|
+
<DownloadUrl ref="images/profile.jpg" let:children let:url let:ref let:storage>
|
|
255
|
+
<img src={url} alt="Profile" />
|
|
256
|
+
</DownloadUrl>
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
#### `StorageList`
|
|
260
|
+
|
|
261
|
+
Lists files and folders in Firebase Storage.
|
|
262
|
+
|
|
263
|
+
```svelte
|
|
264
|
+
<script>
|
|
265
|
+
import { StorageList } from 'svelte-firekit';
|
|
266
|
+
</script>
|
|
267
|
+
|
|
268
|
+
<StorageList ref="images" let:children let:list let:ref let:storage>
|
|
269
|
+
{#each list.items as item}
|
|
270
|
+
<div>{item.name}</div>
|
|
271
|
+
{/each}
|
|
272
|
+
{#each list.prefixes as prefix}
|
|
273
|
+
<div>📁 {prefix.name}</div>
|
|
274
|
+
{/each}
|
|
275
|
+
</StorageList>
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### 🔄 Realtime Database Components
|
|
279
|
+
|
|
280
|
+
#### `Node`
|
|
281
|
+
|
|
282
|
+
Reactive component for Realtime Database nodes.
|
|
283
|
+
|
|
284
|
+
```svelte
|
|
285
|
+
<script>
|
|
286
|
+
import { Node } from 'svelte-firekit';
|
|
287
|
+
</script>
|
|
288
|
+
|
|
289
|
+
<Node path="users/123" let:children let:data let:ref let:database>
|
|
290
|
+
{#if data}
|
|
291
|
+
<h1>{data.name}</h1>
|
|
292
|
+
<p>Status: {data.status}</p>
|
|
293
|
+
{/if}
|
|
294
|
+
</Node>
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
#### `NodeList`
|
|
298
|
+
|
|
299
|
+
Reactive component for Realtime Database lists.
|
|
300
|
+
|
|
301
|
+
```svelte
|
|
302
|
+
<script>
|
|
303
|
+
import { NodeList } from 'svelte-firekit';
|
|
304
|
+
</script>
|
|
305
|
+
|
|
306
|
+
<NodeList path="users" let:children let:data let:ref let:database>
|
|
307
|
+
{#each data as user}
|
|
308
|
+
<div>{user.name} - {user.status}</div>
|
|
309
|
+
{/each}
|
|
310
|
+
</NodeList>
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
## Why Svelte Firekit?
|
|
314
|
+
|
|
315
|
+
- **Zero Configuration**: Automatic Firebase setup through environment variables
|
|
316
|
+
- **Type Safety**: Full TypeScript support with built-in type checking
|
|
317
|
+
- **Rapid Development**: Get your Firebase-powered SvelteKit application up and running in minutes
|
|
318
|
+
- **Best Practices**: Built following Firebase and SvelteKit best practices
|
|
319
|
+
- **Production Ready**: Battle-tested in production environments
|
|
320
|
+
- **Active Community**: Regular updates and active community support
|
|
321
|
+
- **Extensible**: Easy to customize and extend for your specific needs
|
|
322
|
+
|
|
323
|
+
## Next Steps
|
|
324
|
+
|
|
325
|
+
- Check out our [Getting Started](/getting-started) guide
|
|
326
|
+
- Explore the [API Reference](/api)
|
|
327
|
+
- View [Examples](/examples)
|
|
328
|
+
- Join our [Community](/community)
|
|
329
|
+
|
|
330
|
+
## Contributing
|
|
331
|
+
|
|
332
|
+
We welcome contributions! Please see our [Contributing Guide](/contributing) for more details.
|
|
333
|
+
|
|
334
|
+
## License
|
|
335
|
+
|
|
336
|
+
Svelte Firekit is released under the MIT License. See the [LICENSE](/license) file for more details.
|
|
337
|
+
|
|
338
|
+
# Authentication
|
|
339
|
+
|
|
340
|
+
Svelte Firekit provides a comprehensive authentication system through the `firekitAuth` singleton, offering various authentication methods and user management features.
|
|
341
|
+
|
|
342
|
+
## Basic Usage
|
|
343
|
+
|
|
344
|
+
```typescript
|
|
345
|
+
import { firekitAuth } from 'svelte-firekit';
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
## Authentication Methods
|
|
349
|
+
|
|
350
|
+
### Google Authentication
|
|
351
|
+
|
|
352
|
+
```typescript
|
|
353
|
+
await firekitAuth.signInWithGoogle();
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### Email/Password Authentication
|
|
357
|
+
|
|
358
|
+
```typescript
|
|
359
|
+
// Sign in
|
|
360
|
+
await firekitAuth.signInWithEmail(email, password);
|
|
361
|
+
|
|
362
|
+
// Register
|
|
363
|
+
await firekitAuth.registerWithEmail(email, password, displayName);
|
|
364
|
+
|
|
365
|
+
// Sign out
|
|
366
|
+
await firekitAuth.logOut();
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
## User Management
|
|
370
|
+
|
|
371
|
+
### Password Management
|
|
372
|
+
|
|
373
|
+
```typescript
|
|
374
|
+
// Send password reset email
|
|
375
|
+
await firekitAuth.sendPasswordReset(email);
|
|
376
|
+
|
|
377
|
+
// Update password (requires reauthentication)
|
|
378
|
+
await firekitAuth.updateUserPassword(newPassword, currentPassword);
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### Profile Management
|
|
382
|
+
|
|
383
|
+
```typescript
|
|
384
|
+
// Update user profile
|
|
385
|
+
await firekitAuth.updateUserProfile({
|
|
386
|
+
displayName: 'New Name',
|
|
387
|
+
photoURL: 'https://example.com/photo.jpg'
|
|
388
|
+
});
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
### Email Verification
|
|
392
|
+
|
|
393
|
+
```typescript
|
|
394
|
+
// Send verification email
|
|
395
|
+
await firekitAuth.sendEmailVerificationToUser();
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
### Account Deletion
|
|
399
|
+
|
|
400
|
+
```typescript
|
|
401
|
+
// Delete user account
|
|
402
|
+
await firekitAuth.deleteUserAccount();
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
## Automatic Firestore Integration
|
|
406
|
+
|
|
407
|
+
The authentication system automatically maintains a user document in Firestore with the following information:
|
|
408
|
+
|
|
409
|
+
- User ID
|
|
410
|
+
- Email
|
|
411
|
+
- Email verification status
|
|
412
|
+
- Display name
|
|
413
|
+
- Photo URL
|
|
414
|
+
- Authentication provider information
|
|
415
|
+
- Anonymous status
|
|
416
|
+
|
|
417
|
+
## Error Handling
|
|
418
|
+
|
|
419
|
+
All methods include proper error handling and return appropriate error messages. For example, password updates will return:
|
|
420
|
+
|
|
421
|
+
```typescript
|
|
422
|
+
{
|
|
423
|
+
success: boolean;
|
|
424
|
+
message: string;
|
|
425
|
+
code?: string; // In case of errors
|
|
426
|
+
}
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
## Features
|
|
430
|
+
|
|
431
|
+
- 🔐 Multiple authentication providers
|
|
432
|
+
- 📝 Automatic user profile management
|
|
433
|
+
- 🔄 Password reset and update functionality
|
|
434
|
+
- ✉️ Email verification
|
|
435
|
+
- 🗑️ Account deletion
|
|
436
|
+
- 🔄 Reauthentication support
|
|
437
|
+
- 📚 Automatic Firestore user document management
|
|
438
|
+
- ⚡ Type-safe operations
|
|
439
|
+
|
|
440
|
+
## Important Notes
|
|
441
|
+
|
|
442
|
+
1. User data is automatically synchronized with Firestore
|
|
443
|
+
2. Password updates require current password verification
|
|
444
|
+
3. Account deletion removes both authentication and Firestore data
|
|
445
|
+
4. All operations are fully typed for TypeScript support
|