@kerne/react 0.1.0 → 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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Kerne
3
+ Copyright (c) 2026 Kerne
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md ADDED
@@ -0,0 +1,87 @@
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
+
5
+ # @kerne/react
6
+
7
+ Hooks and guard components for integrating Kerne authentication and entitlements into a React app. Never holds a secret key - only your public `appId`.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install @kerne/react
13
+ ```
14
+
15
+ ## Setup
16
+
17
+ ```tsx
18
+ import { KerneProvider } from '@kerne/react';
19
+
20
+ function App() {
21
+ return (
22
+ <KerneProvider appId={process.env.NEXT_PUBLIC_KERNE_APP_ID!}>
23
+ <YourApp />
24
+ </KerneProvider>
25
+ );
26
+ }
27
+ ```
28
+
29
+ ## Authentication
30
+
31
+ ```tsx
32
+ import { useAuth } from '@kerne/react';
33
+
34
+ function LoginForm() {
35
+ const { login, isLoading } = useAuth();
36
+
37
+ return (
38
+ <button onClick={() => login({ email, password })}>
39
+ {isLoading ? 'Loading...' : 'Log in'}
40
+ </button>
41
+ );
42
+ }
43
+ ```
44
+
45
+ ## Gating a feature
46
+
47
+ `Allows` (and the underlying `useAccess` hook) check the logged-in user automatically - no scope to pass, the SDK already knows who's authenticated.
48
+
49
+ ```tsx
50
+ import { Allows } from '@kerne/react';
51
+
52
+ function ExportButton() {
53
+ return (
54
+ <Allows featureKey="export_pdf" fallback={<UpgradePrompt />}>
55
+ <button onClick={exportPdf}>Export as PDF</button>
56
+ </Allows>
57
+ );
58
+ }
59
+ ```
60
+
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')`.
62
+
63
+ ## Checkout & billing portal
64
+
65
+ ```tsx
66
+ import { useCheckout, usePortal } from '@kerne/react';
67
+
68
+ const { openCheckout } = useCheckout();
69
+ const { openPortal } = usePortal();
70
+ ```
71
+
72
+ ## Core Hooks
73
+
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).
75
+ - `useUser`: the current authenticated user's profile.
76
+ - `useAccess`: feature access - `allowed` for the go/no-go, `details` for limit/used/remaining.
77
+ - `useUsage`, `useEntitlements`: usage and full entitlement lists for the current user.
78
+ - `useSubscription`, `usePlans`: the current subscription and the tenant's public plan catalog.
79
+ - `useCheckout`, `usePortal`: hosted checkout and billing-portal sessions.
80
+
81
+ ## Documentation
82
+
83
+ For full React SDK documentation and guides, visit [docs.kerne.io](https://docs.kerne.io/sdks/client/react).
84
+
85
+ ## License
86
+
87
+ MIT