@kerne/react 0.1.1 → 0.1.3

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 CHANGED
@@ -1,3 +1,7 @@
1
+ [![npm version](https://img.shields.io/npm/v/@kerne/react.svg)](https://www.npmjs.com/package/@kerne/react)
2
+ [![npm downloads](https://img.shields.io/npm/dm/@kerne/react.svg)](https://www.npmjs.com/package/@kerne/react)
3
+ [![npm license](https://img.shields.io/npm/l/@kerne/react.svg)](https://www.npmjs.com/package/@kerne/react)
4
+
1
5
  # @kerne/react
2
6
 
3
7
  Hooks and guard components for integrating Kerne authentication and entitlements into a React app. Never holds a secret key - only your public `appId`.
@@ -40,21 +44,21 @@ function LoginForm() {
40
44
 
41
45
  ## Gating a feature
42
46
 
43
- `Allows` (and the underlying `useAllows` hook) check the logged-in user automatically - no scope to pass, the SDK already knows who's authenticated.
47
+ `Allows` (and the underlying `useAccess` hook) check the logged-in user automatically - no scope to pass, the SDK already knows who's authenticated.
44
48
 
45
49
  ```tsx
46
50
  import { Allows } from '@kerne/react';
47
51
 
48
52
  function ExportButton() {
49
53
  return (
50
- <Allows key="export_pdf" fallback={<UpgradePrompt />}>
54
+ <Allows featureKey="export_pdf" fallback={<UpgradePrompt />}>
51
55
  <button onClick={exportPdf}>Export as PDF</button>
52
56
  </Allows>
53
57
  );
54
58
  }
55
59
  ```
56
60
 
57
- For the full detail behind a check (limit/used/remaining, not just a boolean), use `useCheck` instead of `useAllows`.
61
+ For the full detail behind a check (limit/used/remaining, not just a boolean), read `details` from the same hook - `const { allowed, details } = useAccess('api_calls')`.
58
62
 
59
63
  ## Checkout & billing portal
60
64
 
@@ -67,9 +71,9 @@ const { openPortal } = usePortal();
67
71
 
68
72
  ## Core Hooks
69
73
 
70
- - `useAuth`: login, signup, logout, password reset, email verification.
74
+ - `useAuth`: login, signup, logout, password reset, email verification, cross-origin session handoff (`redirectWithSession` - for an app hosting login on a different origin, e.g. a portal).
71
75
  - `useUser`: the current authenticated user's profile.
72
- - `useAllows` / `useCheck`: feature access, boolean or full detail.
76
+ - `useAccess`: feature access - `allowed` for the go/no-go, `details` for limit/used/remaining.
73
77
  - `useUsage`, `useEntitlements`: usage and full entitlement lists for the current user.
74
78
  - `useSubscription`, `usePlans`: the current subscription and the tenant's public plan catalog.
75
79
  - `useCheckout`, `usePortal`: hosted checkout and billing-portal sessions.