@appfunnel-dev/sdk 0.1.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.
package/README.md ADDED
@@ -0,0 +1,91 @@
1
+ # @appfunnel-dev/sdk
2
+
3
+ Headless SDK for building AppFunnel pages with React. Write funnel pages as React components while the SDK handles payments, tracking, navigation, and variable state.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @appfunnel-dev/sdk
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ### 1. Define your config
14
+
15
+ ```ts
16
+ // appfunnel.config.ts
17
+ import { defineConfig } from '@appfunnel-dev/sdk'
18
+
19
+ export default defineConfig({
20
+ projectId: 'clxxx...',
21
+ name: 'My Onboarding Funnel',
22
+ pages: {
23
+ index: { name: 'Landing', type: 'default' },
24
+ quiz: { name: 'Quiz', type: 'default' },
25
+ checkout: { name: 'Checkout', type: 'checkout' },
26
+ success: { name: 'Success', type: 'finish' },
27
+ },
28
+ routes: {
29
+ index: [{ to: 'quiz' }],
30
+ quiz: [
31
+ { to: 'checkout', when: { variable: 'plan', equals: 'premium' } },
32
+ { to: 'success' },
33
+ ],
34
+ checkout: [{ to: 'success' }],
35
+ },
36
+ variables: {
37
+ email: { type: 'string' },
38
+ plan: { type: 'string', default: 'free' },
39
+ },
40
+ products: {
41
+ items: [
42
+ { id: 'monthly', name: 'Monthly Plan', storePriceId: 'clyyy...' },
43
+ { id: 'yearly', name: 'Yearly Plan', storePriceId: 'clzzz...' },
44
+ ],
45
+ defaultId: 'yearly',
46
+ },
47
+ })
48
+ ```
49
+
50
+ ### 2. Write pages
51
+
52
+ ```tsx
53
+ // pages/index.tsx
54
+ import { useVariable, useNavigation } from '@appfunnel-dev/sdk'
55
+
56
+ export default function Landing() {
57
+ const [email, setEmail] = useVariable<string>('email')
58
+ const { goToNextPage } = useNavigation()
59
+
60
+ return (
61
+ <div>
62
+ <h1>Start your journey</h1>
63
+ <input
64
+ type="email"
65
+ value={email}
66
+ onChange={e => setEmail(e.target.value)}
67
+ />
68
+ <button onClick={goToNextPage}>Continue</button>
69
+ </div>
70
+ )
71
+ }
72
+ ```
73
+
74
+ ## Hooks
75
+
76
+ | Hook | Description |
77
+ |------|-------------|
78
+ | `useVariable(id)` | Read/write a single variable with typed actions |
79
+ | `useVariables()` | Read all variables (read-only) |
80
+ | `useNavigation()` | Page navigation, progress, history |
81
+ | `useProducts()` | Product list, selection |
82
+ | `useTracking()` | Event tracking, user identification |
83
+ | `usePayment()` | Payment state (card details, loading, errors) |
84
+ | `useFunnel()` | Convenience — combines all hooks above |
85
+
86
+ ## Components
87
+
88
+ | Component | Description |
89
+ |-----------|-------------|
90
+ | `<PaymentForm>` | Stripe Elements wrapper for card collection & payment |
91
+ | `<PaddleCheckout>` | Paddle checkout (overlay or inline) |