@kerne/react 0.1.1 → 0.1.2
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 +9 -5
- package/dist/chunk-3PROPZWW.cjs +1130 -0
- package/dist/chunk-AIUIBAYB.js +1130 -0
- package/dist/i18n-Qketn1RF.d.cts +241 -0
- package/dist/i18n-Qketn1RF.d.ts +241 -0
- package/dist/index.cjs +80 -817
- package/dist/index.d.cts +154 -77
- package/dist/index.d.ts +154 -77
- package/dist/index.js +43 -719
- package/dist/ui/index.cjs +2984 -0
- package/dist/ui/index.d.cts +391 -0
- package/dist/ui/index.d.ts +391 -0
- package/dist/ui/index.js +2984 -0
- package/package.json +16 -6
package/README.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
[](https://www.npmjs.com/package/@kerne/react)
|
|
2
|
+
[](https://www.npmjs.com/package/@kerne/react)
|
|
3
|
+
[](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 `
|
|
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
|
|
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),
|
|
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
|
-
- `
|
|
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.
|