@outseta/react 0.3.7 → 0.4.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 CHANGED
@@ -1,12 +1,12 @@
1
1
  # @outseta/react
2
2
 
3
- React components plus generated TanStack Query hooks for Outseta.
3
+ React components plus generated data hooks for Outseta.
4
4
 
5
5
  ## Notes
6
6
 
7
- - The embed components depend on `window.Outseta`; load Outseta's script in your app shell before using `OutsetaProvider`.
7
+ - The embed and widget button components depend on `window.Outseta`; load Outseta's script in your app shell before using `OutsetaProvider`.
8
8
  - In browser apps, create API clients with a user bearer `accessToken`, not API key credentials.
9
- - Generated hooks require a TanStack `QueryClientProvider` and an Outseta client passed through each hook's `request` option.
9
+ - Generated hooks are backed by lightweight vanilla-React state (no `QueryClientProvider` required). Pass an Outseta client through each hook's `request` option. They fetch on mount and expose `refetch`, but do not cache, dedupe, or refetch in the background — bring your own data layer (e.g. TanStack Query) if you need that.
10
10
  - `ProtectedRoute` renders generic login/signup and manage-subscription CTAs by default. Replace them with `unauthenticated` and `accessDenied` props when your app needs custom UX.
11
11
 
12
12
  ## Outseta script
@@ -15,12 +15,70 @@ React components plus generated TanStack Query hooks for Outseta.
15
15
  <script>
16
16
  var o_options = {
17
17
  domain: "your-company.outseta.com",
18
- load: "auth,nocode",
18
+ // Include the widget modules you render: auth, profile, support, emailList, leadCapture.
19
+ load: "auth,profile,support,emailList,leadCapture,nocode",
19
20
  };
20
21
  </script>
21
22
  <script src="https://cdn.outseta.com/outseta.min.js" data-options="o_options"></script>
22
23
  ```
23
24
 
25
+ ## Headless widget primitives
26
+
27
+ Components are intentionally unstyled and forward normal DOM props so you can use your own classes, labels, and layout. For design-system components, use `useOutseta()` directly and call `openLogin`, `openSignup`, `openProfile`, `openSupport`, `openEmailList`, or `openLeadCapture` from your own buttons. `EmailListForm` only supplies the Outseta form action; bring your own fields and any honeypot fields Outseta gives you.
28
+
29
+ ```tsx
30
+ import {
31
+ EmailListButton,
32
+ EmailListEmbed,
33
+ EmailListForm,
34
+ LeadCaptureButton,
35
+ LoginButton,
36
+ ProfileButton,
37
+ SignupButton,
38
+ SupportButton,
39
+ SupportEmbed,
40
+ useOutseta,
41
+ } from "@outseta/react";
42
+
43
+ function MarketingPage() {
44
+ const { openSupport } = useOutseta();
45
+
46
+ return (
47
+ <>
48
+ <LoginButton className="btn btn-secondary" />
49
+ <SignupButton className="btn btn-primary">Start free trial</SignupButton>
50
+ <ProfileButton className="link-button" options={{ tab: "billing" }}>
51
+ Billing
52
+ </ProfileButton>
53
+
54
+ <LeadCaptureButton formUid="z9M0zBQ4" className="btn">
55
+ Request a demo
56
+ </LeadCaptureButton>
57
+ <EmailListButton emailListUid="vW5xMZ94" className="btn">
58
+ Join the list
59
+ </EmailListButton>
60
+ <SupportButton className="btn">Contact support</SupportButton>
61
+
62
+ <button type="button" onClick={() => openSupport()}>
63
+ Open support from my own button
64
+ </button>
65
+
66
+ <SupportEmbed className="support-panel" />
67
+ <EmailListEmbed emailListUid="vW5xMZ94" className="newsletter-card" />
68
+
69
+ <EmailListForm
70
+ domain="your-company.outseta.com"
71
+ emailListUid="vW5xMZ94"
72
+ className="newsletter-form"
73
+ >
74
+ <input name="Email" type="email" required />
75
+ <button type="submit">Subscribe</button>
76
+ </EmailListForm>
77
+ </>
78
+ );
79
+ }
80
+ ```
81
+
24
82
  ## Generated hook request client
25
83
 
26
84
  ```tsx
@@ -31,7 +89,19 @@ const client = createClient({
31
89
  accessToken,
32
90
  });
33
91
 
34
- const accounts = useAccountGetAllAccounts(undefined, {
35
- request: client,
36
- });
92
+ function Accounts() {
93
+ const { data, error, isLoading, refetch } = useAccountGetAllAccounts(
94
+ undefined,
95
+ { request: client },
96
+ );
97
+
98
+ if (isLoading) return <p>Loading…</p>;
99
+ if (error) return <p>Something went wrong</p>;
100
+
101
+ return (
102
+ <button type="button" onClick={() => refetch()}>
103
+ Reload {data?.length ?? 0} accounts
104
+ </button>
105
+ );
106
+ }
37
107
  ```