@nimbleflux/fluxbase-sdk-react 2026.3.6-rc.1

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 (42) hide show
  1. package/.nvmrc +1 -0
  2. package/README-ADMIN.md +1076 -0
  3. package/README.md +195 -0
  4. package/examples/AdminDashboard.tsx +513 -0
  5. package/examples/README.md +163 -0
  6. package/package.json +66 -0
  7. package/src/context.test.tsx +147 -0
  8. package/src/context.tsx +33 -0
  9. package/src/index.test.ts +255 -0
  10. package/src/index.ts +175 -0
  11. package/src/test-setup.ts +22 -0
  12. package/src/test-utils.tsx +215 -0
  13. package/src/use-admin-auth.test.ts +175 -0
  14. package/src/use-admin-auth.ts +187 -0
  15. package/src/use-admin-hooks.test.ts +457 -0
  16. package/src/use-admin-hooks.ts +309 -0
  17. package/src/use-auth-config.test.ts +145 -0
  18. package/src/use-auth-config.ts +101 -0
  19. package/src/use-auth.test.ts +313 -0
  20. package/src/use-auth.ts +164 -0
  21. package/src/use-captcha.test.ts +273 -0
  22. package/src/use-captcha.ts +250 -0
  23. package/src/use-client-keys.test.ts +286 -0
  24. package/src/use-client-keys.ts +185 -0
  25. package/src/use-graphql.test.ts +424 -0
  26. package/src/use-graphql.ts +392 -0
  27. package/src/use-query.test.ts +348 -0
  28. package/src/use-query.ts +211 -0
  29. package/src/use-realtime.test.ts +359 -0
  30. package/src/use-realtime.ts +180 -0
  31. package/src/use-saml.test.ts +269 -0
  32. package/src/use-saml.ts +221 -0
  33. package/src/use-storage.test.ts +549 -0
  34. package/src/use-storage.ts +508 -0
  35. package/src/use-table-export.ts +481 -0
  36. package/src/use-users.test.ts +264 -0
  37. package/src/use-users.ts +198 -0
  38. package/tsconfig.json +28 -0
  39. package/tsconfig.tsbuildinfo +1 -0
  40. package/tsup.config.ts +11 -0
  41. package/typedoc.json +33 -0
  42. package/vitest.config.ts +22 -0
package/README.md ADDED
@@ -0,0 +1,195 @@
1
+ # @nimbleflux/fluxbase-sdk-react
2
+
3
+ React hooks for Fluxbase - Backend as a Service.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@nimbleflux/fluxbase-sdk-react.svg)](https://www.npmjs.com/package/@nimbleflux/fluxbase-sdk-react)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ ## Features
9
+
10
+ - **React Hooks** - Idiomatic React hooks for all Fluxbase features
11
+ - **TanStack Query** - Built on React Query for optimal data fetching
12
+ - **Type-safe** - Full TypeScript support
13
+ - **Auto-refetch** - Smart cache invalidation and refetching
14
+ - **Optimistic Updates** - Instant UI updates
15
+ - **SSR Support** - Works with Next.js and other SSR frameworks
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ # npm
21
+ npm install @nimbleflux/fluxbase-sdk @nimbleflux/fluxbase-sdk-react @tanstack/react-query
22
+
23
+ # pnpm
24
+ pnpm add @nimbleflux/fluxbase-sdk @nimbleflux/fluxbase-sdk-react @tanstack/react-query
25
+ ```
26
+
27
+ ## Quick Start
28
+
29
+ ```tsx
30
+ import { createClient } from "@nimbleflux/fluxbase-sdk";
31
+ import { FluxbaseProvider, useAuth, useTable } from "@nimbleflux/fluxbase-sdk-react";
32
+ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
33
+
34
+ // Create clients
35
+ const fluxbaseClient = createClient({ url: "http://localhost:8080" });
36
+ const queryClient = new QueryClient();
37
+
38
+ function App() {
39
+ return (
40
+ <QueryClientProvider client={queryClient}>
41
+ <FluxbaseProvider client={fluxbaseClient}>
42
+ <YourApp />
43
+ </FluxbaseProvider>
44
+ </QueryClientProvider>
45
+ );
46
+ }
47
+
48
+ function YourApp() {
49
+ const { user, signIn, signOut } = useAuth();
50
+ const { data: products } = useTable("products", (q) =>
51
+ q.select("*").eq("active", true).order("created_at", { ascending: false })
52
+ );
53
+
54
+ return (
55
+ <div>
56
+ {user ? (
57
+ <>
58
+ <p>Welcome {user.email}</p>
59
+ <button onClick={signOut}>Sign Out</button>
60
+ </>
61
+ ) : (
62
+ <button
63
+ onClick={() =>
64
+ signIn({ email: "user@example.com", password: "pass" })
65
+ }
66
+ >
67
+ Sign In
68
+ </button>
69
+ )}
70
+
71
+ <h2>Products</h2>
72
+ {products?.map((product) => (
73
+ <div key={product.id}>{product.name}</div>
74
+ ))}
75
+ </div>
76
+ );
77
+ }
78
+ ```
79
+
80
+ ## Available Hooks
81
+
82
+ ### Authentication
83
+
84
+ - `useAuth()` - Complete auth state and methods
85
+ - `useUser()` - Current user data
86
+ - `useSession()` - Current session
87
+ - `useSignIn()` - Sign in mutation
88
+ - `useSignUp()` - Sign up mutation
89
+ - `useSignOut()` - Sign out mutation
90
+ - `useUpdateUser()` - Update user profile
91
+
92
+ ### Database
93
+
94
+ - `useTable()` - Query table with filters and ordering
95
+ - `useFluxbaseQuery()` - Custom query hook
96
+ - `useInsert()` - Insert rows
97
+ - `useUpdate()` - Update rows
98
+ - `useUpsert()` - Insert or update
99
+ - `useDelete()` - Delete rows
100
+ - `useFluxbaseMutation()` - Generic mutation hook
101
+
102
+ ### Realtime
103
+
104
+ - `useRealtime()` - Subscribe to database changes
105
+ - `useTableSubscription()` - Auto-refetch on changes
106
+ - `useTableInserts()` - Listen to inserts
107
+ - `useTableUpdates()` - Listen to updates
108
+ - `useTableDeletes()` - Listen to deletes
109
+
110
+ ### Storage
111
+
112
+ - `useStorageUpload()` - Upload files
113
+ - `useStorageList()` - List files in bucket
114
+ - `useStorageDownload()` - Download files
115
+ - `useStorageDelete()` - Delete files
116
+ - `useStorageSignedUrl()` - Generate signed URLs
117
+ - `useStoragePublicUrl()` - Get public URLs
118
+
119
+ ### RPC (PostgreSQL Functions)
120
+
121
+ - `useRPC()` - Call PostgreSQL function (query)
122
+ - `useRPCMutation()` - Call PostgreSQL function (mutation)
123
+ - `useRPCBatch()` - Call multiple functions in parallel
124
+
125
+ ### Admin (Management & Operations)
126
+
127
+ - `useAdminAuth()` - Admin authentication state and login/logout
128
+ - `useUsers()` - User management with pagination and CRUD
129
+ - `useAPIKeys()` - API key creation and management
130
+ - `useWebhooks()` - Webhook configuration and delivery monitoring
131
+ - `useAppSettings()` - Application-wide settings management
132
+ - `useSystemSettings()` - System key-value settings storage
133
+
134
+ 📚 **[Complete Admin Hooks Guide](./README-ADMIN.md)** - Comprehensive admin dashboard documentation
135
+
136
+ ## Documentation
137
+
138
+ 📚 **[Complete React Hooks Guide](../../docs/docs/sdks/react-hooks.md)**
139
+
140
+ ### Core Guides
141
+
142
+ - **[Getting Started](../../docs/docs/sdks/getting-started.md)** - Installation and setup
143
+ - **[React Hooks](../../docs/docs/sdks/react-hooks.md)** - Comprehensive hooks documentation with examples
144
+ - **[Database Operations](../../docs/docs/sdks/database.md)** - Query building and data operations
145
+
146
+ ### API Reference
147
+
148
+ - **[React Hooks API](../../docs/static/api/sdk-react/)** - Auto-generated from source code
149
+ - **[Core SDK API](../../docs/static/api/sdk/)** - Core TypeScript SDK reference
150
+
151
+ ## TypeScript Support
152
+
153
+ All hooks are fully typed. Define your table schemas for complete type safety:
154
+
155
+ ```typescript
156
+ interface Product {
157
+ id: string
158
+ name: string
159
+ price: number
160
+ category: string
161
+ }
162
+
163
+ function ProductList() {
164
+ const { data } = useTable<Product>('products', (q) => q.select('*'))
165
+ // data is typed as Product[] | undefined
166
+ return <div>{data?.[0]?.name}</div>
167
+ }
168
+ ```
169
+
170
+ ## Examples
171
+
172
+ Check out working examples in the [`/example`](../example/) directory:
173
+
174
+ - React with Vite
175
+ - Next.js App Router
176
+ - Next.js Pages Router
177
+ - Authentication flows
178
+ - Realtime features
179
+ - File uploads
180
+
181
+ ## Contributing
182
+
183
+ Contributions are welcome! Please read our [Contributing Guide](../../CONTRIBUTING.md) for details.
184
+
185
+ ## License
186
+
187
+ MIT © Fluxbase
188
+
189
+ ## Links
190
+
191
+ - [Documentation](../../docs/docs/sdks/react-hooks.md)
192
+ - [API Reference](../../docs/static/api/sdk-react/)
193
+ - [Core SDK](../sdk/)
194
+ - [GitHub](https://github.com/nimbleflux/fluxbase)
195
+ - [Issues](https://github.com/nimbleflux/fluxbase/issues)