@fluxbase/sdk-react 0.0.1-rc.10

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