@growth-rail/react 2.0.1 → 2.0.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.
Files changed (3) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +94 -0
  3. package/package.json +6 -4
package/CHANGELOG.md ADDED
@@ -0,0 +1,39 @@
1
+ # @growth-rail/react
2
+
3
+ ## 2.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - added read me
8
+ - Updated dependencies
9
+ - @growth-rail/core@2.0.1
10
+
11
+ ## 2.0.1
12
+
13
+ ### Patch Changes
14
+
15
+ - dependency fixed
16
+
17
+ ## 2.0.0
18
+
19
+ ### Major Changes
20
+
21
+ - option type changes
22
+
23
+ ## 1.0.1
24
+
25
+ ### Patch Changes
26
+
27
+ - Updated dependencies [d4cc14b]
28
+ - @growth-rail/core@2.0.0
29
+
30
+ ## 1.0.0
31
+
32
+ ### Major Changes
33
+
34
+ - Initial SDK Version
35
+
36
+ ### Patch Changes
37
+
38
+ - Updated dependencies
39
+ - @growth-rail/core@1.0.0
package/README.md ADDED
@@ -0,0 +1,94 @@
1
+ # @growth-rail/react
2
+
3
+ The Official Growth Rail React SDK. Easily integrate referral programs, track user growth, and display referral dashboards in your React applications.
4
+
5
+ ## 🚀 Features
6
+
7
+ - **Context-based Initialization**: Seamless setup with `GrowthRailProvider`.
8
+ - **Hooks for Ease of Use**: Access the SDK anywhere with the `useGrowthRail` hook.
9
+ - **Built-in UI Components**: Drop-in widgets like `ReferralDashboard` to get started instantly.
10
+ - **Fully Type-Safe**: Written in TypeScript with complete definition support.
11
+ - **Small Footprint**: Optimized for performance and minimal bundle size.
12
+
13
+ ## 📦 Installation
14
+
15
+ This package requires `@growth-rail/core` as a dependency and `react` as a peer dependency.
16
+
17
+ ```bash
18
+ # npm
19
+ npm install @growth-rail/react @growth-rail/core
20
+
21
+ # yarn
22
+ yarn add @growth-rail/react @growth-rail/core
23
+
24
+ # pnpm
25
+ pnpm add @growth-rail/react @growth-rail/core
26
+ ```
27
+
28
+ ## 🛠 Usage
29
+
30
+ ### 1. Wrap your App with `GrowthRailProvider`
31
+
32
+ Initialize the SDK at the root of your application. Provide your API Key and optionally a `userId` if the user is already authenticated.
33
+
34
+ ```tsx
35
+ import { GrowthRailProvider } from '@growth-rail/react';
36
+
37
+ function App() {
38
+ return (
39
+ <GrowthRailProvider
40
+ apiKey="your_api_key_here"
41
+ userId="user_123" // Optional: initialize for a specific user
42
+ >
43
+ <your-application-code />
44
+ </GrowthRailProvider>
45
+ );
46
+ }
47
+ ```
48
+
49
+ ### 2. Track Events and Get User Info
50
+
51
+ Use the `useGrowthRail` hook in any child component to track referrals or retrieve user details.
52
+
53
+ ```tsx
54
+ import { useGrowthRail } from '@growth-rail/react';
55
+
56
+ export function InviteButton() {
57
+ const { trackReferral, getUserId } = useGrowthRail();
58
+
59
+ const handleInvite = async (code: string) => {
60
+ await trackReferral(code);
61
+ console.log('Referral tracked for user:', getUserId());
62
+ };
63
+
64
+ return <button onClick={() => handleInvite('FRIEND_CODE')}>Use Invite</button>;
65
+ }
66
+ ```
67
+
68
+ ### 3. Display the Referral Dashboard
69
+
70
+ Use the `ReferralDashboard` component to provide a white-labeled UI where users can see their referral link and rewards.
71
+
72
+ ```tsx
73
+ import { ReferralDashboard } from '@growth-rail/react';
74
+
75
+ export function DashboardPage() {
76
+ return (
77
+ <div style={{ padding: '20px' }}>
78
+ <h1>My Rewards</h1>
79
+ <ReferralDashboard
80
+ title="Invite your friends and earn!"
81
+ onLinkCopied={() => alert('Link copied!')}
82
+ />
83
+ </div>
84
+ );
85
+ }
86
+ ```
87
+
88
+ ## 📖 Documentation
89
+
90
+ For full documentation and advanced configuration, visit [docs.growthrail.com](https://docs.growthrail.com).
91
+
92
+ ## 📄 License
93
+
94
+ MIT © [Growth Rail](https://growthrail.com)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@growth-rail/react",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "Growth Rail React SDK",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -13,7 +13,9 @@
13
13
  }
14
14
  },
15
15
  "files": [
16
- "dist"
16
+ "dist",
17
+ "README.md",
18
+ "CHANGELOG.md"
17
19
  ],
18
20
  "scripts": {
19
21
  "build": "tsup",
@@ -27,7 +29,7 @@
27
29
  "react-dom": ">=16.8"
28
30
  },
29
31
  "dependencies": {
30
- "@growth-rail/core": "^2.0.0"
32
+ "@growth-rail/core": "^2.0.1"
31
33
  },
32
34
  "devDependencies": {
33
35
  "@growth-rail/eslint-config": "*",
@@ -45,4 +47,4 @@
45
47
  "publishConfig": {
46
48
  "access": "public"
47
49
  }
48
- }
50
+ }