@nosto/nosto-react 0.1.9 → 0.1.10
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 +27 -22
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
# React
|
|
1
|
+
# Nosto React
|
|
2
2
|
|
|
3
|
-
React
|
|
3
|
+
Nosto React is a React component library to make it even easier to implement Nosto.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The library provides you everything to get started with personalisation on your React site. It's dead simple, and beginner friendly.
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
### Why
|
|
9
|
+
### Why?
|
|
10
10
|
|
|
11
|
-
You should be using React
|
|
11
|
+
You should be using Nosto React if you want to:
|
|
12
12
|
|
|
13
13
|
- Design personalisation experiences with best practices
|
|
14
|
-
- Customize your components at will
|
|
14
|
+
- Customize your components at will and with ease
|
|
15
15
|
- Follow React principles
|
|
16
16
|
|
|
17
17
|
|
|
@@ -19,12 +19,14 @@ You should be using React Nosto if you want to:
|
|
|
19
19
|
### Features
|
|
20
20
|
|
|
21
21
|
- ✓ Lightweight. Almost zero bloat.
|
|
22
|
-
- ✓ Full support for the Facebook Pixel and Google Analytics
|
|
22
|
+
- ✓ Full support for the Facebook Pixel and Google Analytics.
|
|
23
23
|
- ✓ Full support for leveraging overlays.
|
|
24
|
-
- ✓ Full support for placements and dynamic placements.
|
|
25
24
|
- ✓ Full support for the JS API.
|
|
26
|
-
-
|
|
27
|
-
-
|
|
25
|
+
- ✓ Full support for placements*.
|
|
26
|
+
- ✓ Partial support for Nosto's Debug Toolbar. Supports most use-cases with page tagging and debug workflows.
|
|
27
|
+
- ✘ No support for client-side rendering (SSR) for recommendations and content, yet.
|
|
28
|
+
|
|
29
|
+
_*Note: dynamic placements are not supported on Shopify Hydrogen due to the React framework explicitly restricting injecting DOM elements in this way. This can be disabled explicitly via configuration. Static placements continue to be supported fully. Please see `<NostoPlacement>` below for more details._
|
|
28
30
|
|
|
29
31
|
### Building
|
|
30
32
|
|
|
@@ -48,14 +50,14 @@ You should be using React Nosto if you want to:
|
|
|
48
50
|
|
|
49
51
|
##### The root widget
|
|
50
52
|
|
|
51
|
-
There’s one very specific widget in React
|
|
53
|
+
There’s one very specific widget in Nosto React and it is the `NostoProvider` one.
|
|
52
54
|
|
|
53
55
|
This widget is what we call the Nosto root widget, which is responsible for adding the actual Nosto script and the JS API stub. This widget wraps all other React Nosto widgets. Here’s how:
|
|
54
56
|
|
|
55
57
|
```tsx
|
|
56
58
|
import { NostoProvider } from "@nosto/nosto-react";
|
|
57
59
|
|
|
58
|
-
<NostoProvider account="
|
|
60
|
+
<NostoProvider account="your-nosto-account-id">
|
|
59
61
|
<App />
|
|
60
62
|
</NostoProvider>
|
|
61
63
|
```
|
|
@@ -66,15 +68,15 @@ import { NostoProvider } from "@nosto/nosto-react";
|
|
|
66
68
|
|
|
67
69
|
##### Understanding Placements
|
|
68
70
|
|
|
69
|
-
React
|
|
71
|
+
Nosto React has a special component called `NostoPlacement`. The component is a simply a <u>hidden</u> `<div>` placeholder into which Nosto injects recommendations or personalises the content between the tags.
|
|
70
72
|
|
|
71
73
|
We recommend adding as many placements across your views as needed as these are hidden and only populated when a corresponding campaign (targeting that placement) is configured.
|
|
72
74
|
|
|
73
75
|
|
|
74
76
|
|
|
75
77
|
##### Managing the session
|
|
76
|
-
|
|
77
|
-
React
|
|
78
|
+
|
|
79
|
+
Nosto React requires that you pass it the details of current cart contents and the details of the currently logged-in customer, if any, on every route change. This makes it easier to add attribution.
|
|
78
80
|
|
|
79
81
|
The `NostoSession` component makes it very easy to keep the session up to date so long as the cart and the customer are provided.
|
|
80
82
|
|
|
@@ -98,9 +100,9 @@ import { Cart, Customer, Item, NostoSession } from "@nosto/nosto-react";
|
|
|
98
100
|
|
|
99
101
|
|
|
100
102
|
|
|
101
|
-
|
|
103
|
+
### Adding Personalisation
|
|
102
104
|
|
|
103
|
-
React
|
|
105
|
+
Nosto React ships with canned components for the different page types. Each component contains all lifecycle methods to dispatch the necessary events.
|
|
104
106
|
|
|
105
107
|
|
|
106
108
|
|
|
@@ -110,6 +112,8 @@ The `NostoHome` component must be used to personalise the home page. The compone
|
|
|
110
112
|
|
|
111
113
|
By default, your account, when created, has <u>four</u> front-page placements named `frontpage-nosto-1`, `frontpage-nosto-2`, `frontpage-nosto-3` and `frontpage-nosto-4`. You may omit these and use any identifier you need. The identifiers used here are simply provided to illustrate the example.
|
|
112
114
|
|
|
115
|
+
The `<NostoHome \>` component needs to be added after the placements. Content and recommendations will be rendered through this component.
|
|
116
|
+
|
|
113
117
|
```tsx
|
|
114
118
|
import { NostoHome, NostoPlacement } from "@nosto/nosto-react";
|
|
115
119
|
|
|
@@ -133,6 +137,8 @@ The `NostoProduct` component must be used to personalise the product page. The c
|
|
|
133
137
|
|
|
134
138
|
By default, your account, when created, has <u>three</u> product-page placements named `productpage-nosto-1`, `productpage-nosto-2` and `productpage-nosto-3`. You may omit these and use any identifier you need. The identifiers used here are simply provided to illustrate the example.
|
|
135
139
|
|
|
140
|
+
The `<NostoProduct \>` component needs to be added after the placements. Content and recommendations will be rendered through this component. Pass in the product ID via the `product` prop to pass this information back to Nosto.
|
|
141
|
+
|
|
136
142
|
```tsx
|
|
137
143
|
import { NostoPlacement, NostoProduct } from "@nosto/nosto-react";
|
|
138
144
|
|
|
@@ -204,12 +210,12 @@ By default, your account, when created, has <u>two</u> cart-page placements name
|
|
|
204
210
|
```tsx
|
|
205
211
|
import { NostoCheckout, NostoPlacement } from "@nosto/nosto-react";
|
|
206
212
|
|
|
207
|
-
<div className="-page">
|
|
213
|
+
<div className="checkout-page">
|
|
208
214
|
...
|
|
209
215
|
...
|
|
210
216
|
...
|
|
211
|
-
<NostoPlacement id="
|
|
212
|
-
<NostoPlacement id="
|
|
217
|
+
<NostoPlacement id="checkout-nosto-1" />
|
|
218
|
+
<NostoPlacement id="checkout-nosto-2" />
|
|
213
219
|
<NostoCheckout />
|
|
214
220
|
</div>
|
|
215
221
|
```
|
|
@@ -247,7 +253,7 @@ By default, your account, when created, has two other-page placements named `oth
|
|
|
247
253
|
```tsx
|
|
248
254
|
import { NostoOther, NostoPlacement } from "@nosto/nosto-react";
|
|
249
255
|
|
|
250
|
-
<div className="
|
|
256
|
+
<div className="other-page">
|
|
251
257
|
...
|
|
252
258
|
...
|
|
253
259
|
...
|
|
@@ -279,7 +285,6 @@ import { Buyer, Item, NostoOrder, NostoPlacement, Purchase } from "@nosto/nosto-
|
|
|
279
285
|
</div>
|
|
280
286
|
```
|
|
281
287
|
|
|
282
|
-
|
|
283
288
|
### Feedback
|
|
284
289
|
|
|
285
290
|
If you've found a feature missing or you would like to report an issue, simply [open up an issue](https://github.com/nosto/nosto-react/issues/new) and let us know.
|
package/package.json
CHANGED