@nosto/nosto-react 0.1.9 → 0.1.11
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 +39 -34
- 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
|
|
|
@@ -40,7 +42,7 @@ You should be using React Nosto if you want to:
|
|
|
40
42
|
|
|
41
43
|
##### NPM:
|
|
42
44
|
|
|
43
|
-
npm install
|
|
45
|
+
npm install @nosto/nosto-react
|
|
44
46
|
|
|
45
47
|
|
|
46
48
|
|
|
@@ -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
|
+
```jsx
|
|
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,22 +68,22 @@ 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
|
|
|
81
83
|
The `cart` prop requires a value that adheres to the type `Cart`, while the `customer` prop requires a value that adheres to the type `Customer`.
|
|
82
84
|
|
|
83
|
-
```
|
|
84
|
-
import {
|
|
85
|
+
```jsx
|
|
86
|
+
import { NostoSession } from "@nosto/nosto-react";
|
|
85
87
|
|
|
86
88
|
<>
|
|
87
89
|
<Meta/>
|
|
@@ -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,7 +112,9 @@ 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
|
|
|
113
|
-
|
|
115
|
+
The `<NostoHome \>` component needs to be added after the placements. Content and recommendations will be rendered through this component.
|
|
116
|
+
|
|
117
|
+
```jsx
|
|
114
118
|
import { NostoHome, NostoPlacement } from "@nosto/nosto-react";
|
|
115
119
|
|
|
116
120
|
<div className="front-page">
|
|
@@ -133,7 +137,9 @@ 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
|
|
|
136
|
-
|
|
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
|
+
|
|
142
|
+
```jsx
|
|
137
143
|
import { NostoPlacement, NostoProduct } from "@nosto/nosto-react";
|
|
138
144
|
|
|
139
145
|
<div className="product-page">
|
|
@@ -155,7 +161,7 @@ You can personalise your search pages by using the `NostoSearch` component. The
|
|
|
155
161
|
|
|
156
162
|
By default, your account, when created, has <u>two</u> search-page placements named `searchpage-nosto-1` and `searchpage-nosto-2`. You may omit these and use any identifier you need. The identifiers used here are simply provided to illustrate the example.
|
|
157
163
|
|
|
158
|
-
```
|
|
164
|
+
```jsx
|
|
159
165
|
import { NostoPlacement, NostoSearch } from "@nosto/nosto-react";
|
|
160
166
|
|
|
161
167
|
<div className="search-page">
|
|
@@ -178,7 +184,7 @@ You can personalise your category and collection pages by using the `NostoCatego
|
|
|
178
184
|
|
|
179
185
|
By default, your account, when created, has <u>two</u> category placements named `categorypage-nosto-1` and `categorypage-nosto-2`. You may omit these and use any identifier you need. The identifiers used here are simply provided to illustrate the example.
|
|
180
186
|
|
|
181
|
-
```
|
|
187
|
+
```jsx
|
|
182
188
|
import { NostoCategory, NostoPlacement } from "@nosto/nosto-react";
|
|
183
189
|
|
|
184
190
|
<div className="category-page">
|
|
@@ -201,15 +207,15 @@ You can personalise your cart and checkout pages by using the `NostoCheckout` co
|
|
|
201
207
|
|
|
202
208
|
By default, your account, when created, has <u>two</u> cart-page placements named `categorypage-nosto-1` and `categorypage-nosto-2`. You may omit these and use any identifier you need. The identifiers used here are simply provided to illustrate the example.
|
|
203
209
|
|
|
204
|
-
```
|
|
210
|
+
```jsx
|
|
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
|
```
|
|
@@ -222,7 +228,7 @@ You can personalise your cart and checkout pages by using the `Nosto404` compone
|
|
|
222
228
|
|
|
223
229
|
By default, your account, when created, has three 404-page placements named `notfound-nosto-1`, `notfound-nosto-2` and `notfound-nosto-2`. You may omit these and use any identifier you need. The identifiers used here are simply provided to illustrate the example.
|
|
224
230
|
|
|
225
|
-
```
|
|
231
|
+
```jsx
|
|
226
232
|
import { Nosto404, NostoPlacement } from "@nosto/nosto-react";
|
|
227
233
|
|
|
228
234
|
<div className="notfound-page">
|
|
@@ -244,10 +250,10 @@ You can personalise your miscellaneous pages by using the `NostoOther` component
|
|
|
244
250
|
|
|
245
251
|
By default, your account, when created, has two other-page placements named `other-nosto-1` and `other-nosto-2`. You may omit these and use any identifier you need. The identifiers used here are simply provided to illustrate the example.
|
|
246
252
|
|
|
247
|
-
```
|
|
253
|
+
```jsx
|
|
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
|
...
|
|
@@ -267,7 +273,7 @@ By default, your account, when created, has one other-page placement named `than
|
|
|
267
273
|
|
|
268
274
|
The `order` prop requires a value that adheres to the type `Purchase`.
|
|
269
275
|
|
|
270
|
-
```
|
|
276
|
+
```jsx
|
|
271
277
|
import { Buyer, Item, NostoOrder, NostoPlacement, Purchase } from "@nosto/nosto-react";
|
|
272
278
|
|
|
273
279
|
<div className="thankyou-page">
|
|
@@ -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