@schematichq/schematic-components 2.2.0 → 2.3.1

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
@@ -14,8 +14,60 @@ pnpm add @schematichq/schematic-components
14
14
 
15
15
  ## Usage
16
16
 
17
+ Import components and functions and compose them into your project.
18
+
19
+ ```js
20
+ import { EmbedProvider, SchematicEmbed, useEmbed } from '@schematichq/schematic-components';
21
+ ```
22
+
17
23
  See the [Schematic documentation](https://docs.schematichq.com/components/set-up) for a full guide on how to set up and use Schematic components.
18
24
 
25
+ ## Advanced Checkout Usage
26
+
27
+ We provide a function `initializeWithPlan` as an alternate entrypoint into a
28
+ checkout flow. It's suitable for click handlers, and must be extracted from
29
+ the library's embedded context.
30
+
31
+ ```ts
32
+ const { initializeWithPlan } = useEmbed();
33
+ ```
34
+
35
+ This function allows developers to create their own button that
36
+
37
+ * Pre-selects a Plan
38
+ * Pre-selects Add-ons (if available)
39
+ * Skips and hides plan selection stages
40
+
41
+ The `initializeWithPlan` function can be called with a Schematic plan ID, or
42
+ with a more powerful `BypassConfig` object.
43
+
44
+ Providing a plan ID as a string will preselect that plan and skip the plan
45
+ selection stage.
46
+
47
+ ```ts
48
+ initializeWithPlan('plan_VBXv4bHjSf3');
49
+ ```
50
+
51
+ Passing a config object allows pre-selecting Add-ons as well as hiding
52
+ specific stages.
53
+
54
+ ```ts
55
+ const config = {
56
+ planId: 'plan_VBXv4bHjSf3', // pre-select a Plan
57
+ addOnIds: ['plan_AWv7bPjSx2'], // pre-select 1 or more Add-ons
58
+ skipped: {
59
+ planStage: true, // if true, skip Plan selection
60
+ addOnStage: true // if true, skip Add-on selection
61
+ }
62
+ hideSkipped: true // if true, hide skipped stages from breadcrumb navigation
63
+ };
64
+
65
+ initializeWithPlan(config);
66
+ ```
67
+
68
+ The Plans and Add-ons available to the checkout flows must be live in your
69
+ Schematic account [Catalog configuration](https://docs.schematichq.com/catalog/overview).
70
+
19
71
  ## License
20
72
 
21
73
  MIT