@proappstore/sdk 1.6.1 → 1.7.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.
Files changed (2) hide show
  1. package/README.md +61 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -170,6 +170,67 @@ const response = await app.storage.download('docs/resume.pdf')
170
170
  await app.storage.delete('docs/resume.pdf')
171
171
  ```
172
172
 
173
+ ## React Hooks (recommended)
174
+
175
+ Hooks give you full control over your UI while the platform handles auth, subscriptions, and gating. Import from `@proappstore/sdk/hooks`.
176
+
177
+ ### useProAuth
178
+
179
+ Auth state + actions. The primary way apps interact with platform identity.
180
+
181
+ ```tsx
182
+ import { initPro } from '@proappstore/sdk'
183
+ import { useProAuth } from '@proappstore/sdk/hooks'
184
+
185
+ const app = initPro({ appId: 'my-app' })
186
+
187
+ function App() {
188
+ const { user, loading, signIn, signOut, deleteAccount } = useProAuth(app)
189
+ if (loading) return <p>Loading...</p>
190
+ if (!user) return <button onClick={signIn}>Sign in with GitHub</button>
191
+ return <p>Welcome, {user.login}! <button onClick={signOut}>Sign out</button></p>
192
+ }
193
+ ```
194
+
195
+ ### useProSubscription
196
+
197
+ Subscription state + actions. Check if user is subscribed, upgrade, manage billing.
198
+
199
+ ```tsx
200
+ import { useProSubscription } from '@proappstore/sdk/hooks'
201
+
202
+ function Billing() {
203
+ const { subscription, isPro, loading, upgrade, manageBilling } = useProSubscription(app)
204
+ if (loading) return <p>Loading...</p>
205
+ if (!isPro) return <button onClick={() => upgrade()}>Upgrade to Pro</button>
206
+ return <button onClick={manageBilling}>Manage billing</button>
207
+ }
208
+ ```
209
+
210
+ ### useProGate
211
+
212
+ Combined auth + subscription gate. Returns a single `gate` state for easy conditional rendering.
213
+
214
+ ```tsx
215
+ import { initPro } from '@proappstore/sdk'
216
+ import { useProGate } from '@proappstore/sdk/hooks'
217
+
218
+ const app = initPro({ appId: 'my-app' })
219
+
220
+ function App() {
221
+ const { gate, user, signIn, upgrade } = useProGate(app, { allowFree: true })
222
+
223
+ if (gate === 'loading') return <p>Loading...</p>
224
+ if (gate === 'signed-out') return <button onClick={signIn}>Sign in</button>
225
+ if (gate === 'no-subscription') return <button onClick={() => upgrade()}>Upgrade</button>
226
+ return <p>Welcome, {user?.login}!</p>
227
+ }
228
+ ```
229
+
230
+ Gate states: `'loading'` | `'signed-out'` | `'no-subscription'` | `'ready'`
231
+
232
+ Pass `{ allowFree: true }` to skip the subscription check (lets free users through).
233
+
173
234
  ## ProShell Component
174
235
 
175
236
  A React component that handles auth gates, subscription checks, and renders a platform-level shell with topbar and user menu.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proappstore/sdk",
3
- "version": "1.6.1",
3
+ "version": "1.7.0",
4
4
  "description": "Browser SDK for paid apps on proappstore.online — subscriptions, license keys, premium modules.",
5
5
  "license": "MIT",
6
6
  "type": "module",